锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 銆銆娉ㄦ剰錛歷i鍛戒護騫朵笉閿佷綇鎵緙栬緫鐨勬枃浠訛紝鍥犳澶氫釜鐢ㄦ埛鍙兘鍦ㄥ悓鏃剁紪杈戜竴涓枃浠訛紝閭d箞鏈鍚幝?br />淇濆瓨鐨勬枃浠剁増鏈皢琚繚鐣欍偮?/p> 涓嬮潰鏄痸i鍛戒護浣跨敤鐨勪竴浜涢夐」鍙婂惈涔夛細聽聽聽聽聽聽聽聽聽聽 銆銆-c聽sub-command聽鍦ㄥ鎸囧畾鐨勬枃浠剁紪杈戝墠錛屽厛鎵ц鎸囧畾鐨勫懡浠ぢ爏ub-command聽.聽 銆銆-r聽filename聽鎭㈠鎸囧畾鐨勬枃浠秄ilename聽.聽聽聽聽聽聽聽聽聽聽 銆銆-R聽灝嗘寚瀹氱殑鏂囦歡浠ュ彧璇葷殑鏂瑰紡鏀懼叆緙栬緫鍣ㄤ腑錛岃繖鏍蜂笉浼氫繚瀛樺鏂囦歡鐨勪換浣曚慨聽鏀廣偮?/p> 銆銆-y聽number聽灝嗙紪杈戠獥鍙g殑澶у皬璁句負number琛屻偮犅犅犅犅犅犅犅犅犅?/p> 銆銆涓嬮潰鏄痸i緙栬緫鎵澶勭殑涓夌妯″紡錛毬犅犅犅犅犅犅犅犅犅?/p> 銆銆.鍛戒護妯″紡聽榪涘叆vi鏃舵墍澶勭殑妯″紡銆傚湪姝ゆā寮忎笅鐢ㄦ埛鍙緭鍏ュ悇縐嶅瓙鍛戒護瀵硅繘琛?浣滐紝濡傚垹闄よ銆伮?br />綺樿創琛屻佺Щ鍚戜笅涓涓瓧銆佺Щ鍚戜笉鍚岃絳夈偮?/p> 銆銆.鏂囨湰杈撳叆妯″紡聽鍦ㄦ妯″紡涓嬪彲浠ヤ慨鏀逛竴琛岀殑鍐呭騫跺娣繪柊琛屻傚湪鍛戒護妯″紡涓嬮敭鍏聽銆乮聽鎴柭?br />c閿彲榪涘叆鏂囨湰杈撳叆妯″紡錛屾寜Escape閿彲榪斿洖鍛戒護妯″紡銆偮?/p> 銆銆.鍛戒護欏規ā寮徛犲湪姝ゆā寮忎笅錛屽彲浠ラ氳繃瀛愬懡浠よ緭鍏ユ洿澶氱殑鍙傛暟銆傚錛歸瀛愬懡浠よ姹傝緭鍏ヤ竴鏂嚶?br />浠跺悕錛?/"瀛愬懡浠よ姹傝緭鍏ヤ竴涓煡鎵鵑」銆傜敤鎴蜂嬌鐢‥scape閿繑鍥炲懡浠ゆā寮忋偮?/p> 銆銆h聽灝嗗厜鏍囧乏縐諱竴鏍箋偮犅犅犅犅犅犅犅犅犅?/p> 銆銆l聽灝嗗厜鏍囧彸縐諱竴鏍箋偮犅犅犅犅犅犅犅犅犅?/p> 銆銆j聽灝嗗厜鏍囦笅縐諱竴鏍箋偮犅犅犅犅犅犅犅犅犅?/p> 銆銆k聽灝嗗厜鏍囦笂縐諱竴鏍箋偮犅犅犅犅犅犅犅犅犅?/p> 銆銆w聽灝嗗厜鏍囩Щ鍒頒笅涓涓皬瀛楃殑鍓嶉潰銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆W聽灝嗗厜鏍囩Щ鍒頒笅涓涓ぇ瀛楃殑鍓嶉潰銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆b聽灝嗗厜鏍囩Щ鍒板墠涓涓皬瀛楃殑鍓嶉潰銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆B聽灝嗗厜鏍囩Щ鍒板墠涓涓ぇ瀛楃殑鍓嶉潰銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆e聽灝嗗厜鏍囩Щ鍒頒笅涓涓皬瀛楃殑鍚庨潰銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆E聽灝嗗厜鏍囩Щ鍒板墠涓涓ぇ瀛楃殑鍚庨潰銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆fc聽鎶婂厜鏍囩Щ鍒板悓涓琛岀殑涓嬩竴涓猚瀛楃澶勩偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Fc聽鎶婂厜鏍囩Щ鍒板悓涓琛岀殑鍓嶄竴涓猚瀛楃澶勩偮犅犅犅犅犅犅犅犅犅?/p> 銆銆tc聽鎶婂厜鏍囩Щ鍒板悓涓琛岀殑涓嬩竴涓瓧絎鐨勫墠涓鏍箋偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Tc聽鎶婂厜鏍囩Щ鍒板悓涓琛岀殑鍓嶄竴涓瓧絎鐨勫悗涓鏍箋偮犅犅犅犅犅犅犅犅犅?/p> 銆銆number|聽鎶婂厜鏍囩Щ鍒伴抧umber鍒椾笂銆偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄懡浠ゆā寮忎笅鍦ㄨ闂寸Щ鍔ㄧ殑瀛愬懡浠わ細聽聽聽聽聽聽聽聽聽聽 銆銆+鎴朎nter聽鎶婂厜鏍囩Щ鑷充笅涓琛岀涓涓潪絀虹櫧瀛楃銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆-聽鎶婂厜鏍囩Щ鑷充笂涓琛岀涓涓潪絀虹櫧瀛楃銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆0聽鎶婂厜鏍囩Щ鍒板綋鍓嶈鐨勭涓涓瓧絎﹀銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆$聽鎶婂厜鏍囩Щ鍒板綋鍓嶈鐨勬渶鍚庝竴涓瓧絎﹀銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆H聽鎶婂厜鏍囩Щ鍒板睆騫曟渶欏剁涓琛屻偮犅犅犅犅犅犅犅犅犅?/p> 銆銆L聽鎶婂厜鏍囩Щ鍒板睆騫曟渶搴曠涓琛屻偮犅犅犅犅犅犅犅犅犅?/p> 銆銆M聽鎶婂厜鏍囩Щ鍒板睆騫曚腑闂淬偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄懡浠ゆā寮忎笅鏀瑰彉灞忓箷鏄劇ず鐨勫瓙鍛戒護錛毬犅犅犅犅犅犅犅犅犅?/p> 銆銆z-聽鎶婂綋鍓嶈浣滀負灞忓箷鐨勬渶鍚庝竴琛岋紝騫墮噸鏂版樉紺哄睆騫曘偮犅犅犅犅犅犅犅犅犅?/p> 銆銆z.聽鎶婂綋鍓嶈浣滀負灞忓箷鐨勪腑闂翠竴琛岋紝騫墮噸鏂版樉紺哄睆騫曘偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Ctrl+l聽閲嶆柊鏄劇ず灞忓箷褰撳墠鍐呭銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆/pattern/z-聽瀵繪壘pattern鐨勪笅涓涓綅緗紝騫舵妸鎵鍦ㄨ璁句負灞忓箷鐨勬渶鍚庝竴琛屻偮?/p> 涓嬮潰鏄湪鍛戒護妯″紡涓嬬敤鏉ユ樉紺洪〉闈㈢殑瀛愬懡浠わ細聽聽聽聽聽聽聽聽聽聽 銆銆Ctrl聽+聽f鍚戝悗婊氫竴欏點偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Ctrl聽+聽d鍚戝悗婊氬崐欏點偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Ctrl聽+聽b鍚戝墠婊氫竴欏點偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Ctrl聽+聽u鍚戝墠婊氬崐欏點偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Ctrl聽+聽e灞忓箷鍚戜笅婊氫竴琛屻偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Ctrl聽+聽y灞忓箷欏逛笂婊氫竴琛屻偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄湪鍛戒護妯″紡涓嬬敤鏉ユ煡鎵懼瓧絎︿覆鎵浣跨敤鐨勫瓙鍛戒護錛毬犅犅犅犅犅犅犅犅犅?/p> 銆銆/pattern聽鍚戝悗瀵繪壘鎸囧畾鐨刾attern聽,鑻ラ亣鍒版枃浠跺熬錛屽垯浠庡ご鍐嶅紑濮嬨偮?/p> 銆銆錛焢attern聽鍚戝墠瀵繪壘鎸囧畾鐨刾attern聽,鑻ラ亣鍒版枃浠跺ご錛屽垯浠庡熬鍐嶅紑濮嬨偮?/p> 銆銆n聽鍦ㄤ笂嬈℃寚瀹氱殑鏂瑰悜涓婏紝鍐嶆鎵ц涓婃瀹氫箟鐨勬煡鎵俱偮犅犅犅犅犅犅犅犅犅?/p> 銆銆N聽鍦ㄤ笂嬈℃寚瀹氱殑鏂瑰悜鐨勭浉鍙嶆柟鍚戜笂錛屽啀嬈℃墽琛屼笂嬈″畾涔夌殑鏌ユ壘銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆/pattern/+number聽灝嗗厜鏍囧仠鍦ㄥ寘鍚玴attern鐨勮鍚庨潰絎琻umber琛屼笂銆偮?/p> 銆銆/pattern/-number聽灝嗗厜鏍囧仠鍦ㄥ寘鍚玴attern鐨勮鍓嶉潰絎琻umber琛屼笂銆偮?/p> 銆銆%聽縐誨埌鍖歸厤鐨?錛堬級"鎴?{}"涓娿偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄湪鏂囨湰杈撳叆妯″紡涓嬬敤鏉ヨ緭鍏ユ枃鏈殑瀛愬懡浠わ紙鐢ㄦ埛鍙湪浠諱綍鏃跺欐寜Escape榪斿洖鍒板懡浠ゆā寮忥級錛毬?/p> 銆銆a聽鍦ㄥ厜鏍囦箣鍚庡紑濮嬭緭鍏ユ枃鏈偮犅犅犅犅犅犅犅犅犅?/p> 銆銆A鍦ㄨ灝懼紑濮嬭緭鍏ユ枃鏈偮犅犅犅犅犅犅犅犅犅?/p> 銆銆i鍦ㄥ厜鏍囦箣鍓嶅紑濮嬭緭鍏ユ枃鏈偮犅犅犅犅犅犅犅犅犅?/p> 銆銆I鍦ㄨ棣栫涓涓潪絀虹櫧瀛楃鍓嶈緭鍏ユ枃鏈偮犅犅犅犅犅犅犅犅犅?/p> 銆銆o鍦ㄥ厜鏍囨墍鍦ㄨ鍚庢彃鍏ヤ竴絀鴻銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆O鍦ㄥ厜鏍囨墍鍦ㄨ鍓嶆彃鍏ヤ竴絀鴻銆偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄湪鍛戒護妯″紡涓嬫敼鍙樻枃鏈墍浣跨敤鐨勫瓙鍛戒護錛堢敤鎴峰彲鍦ㄤ換浣曠殑鏃跺欐寜Escape閿繑鍥炲埌鍛戒護妯″紡錛夛細聽 銆銆cc鎴朣聽淇敼涓鏁磋銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆C聽鏀瑰彉涓琛屽厜鏍囦綅緗互鍚庣殑閮ㄥ垎銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆cw聽鏀瑰彉鍏夋爣鎵鍦ㄥ崟璇嶃偮犅犅犅犅犅犅犅犅犅?/p> 銆銆dd鍒犻櫎褰撳墠琛屻偮犅犅犅犅犅犅犅犅犅?/p> 銆銆D聽鍒犻櫎鍏夋爣鎵鍦ㄨ鍏夋爣鍚庨潰鐨勫唴瀹廣偮犅犅犅犅犅犅犅犅犅?/p> 銆銆dw鍒犻櫎鍏夋爣鎵鍦ㄧ殑鍗曡瘝銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆J聽鎶婁笅涓琛屽唴瀹瑰姞鍒版湰琛岃灝俱偮犅犅犅犅犅犅犅犅犅?/p> 銆銆rc鎶婂厜絎︽墍鍦ㄥ瓧絎︽浛鎹㈡垚c聽.聽聽聽聽聽聽聽聽聽聽 銆銆R聽瑕嗙洊鏈鍐呭銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆u鎭㈠涓婁竴嬈$殑淇敼銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆x鍒犻櫎鍏夋爣鎵鍦ㄧ殑瀛楃銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆~聽鏀瑰彉鍏夋爣鎵鍦ㄥ嚭瀛楃鐨勫ぇ灝忓啓銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆.聽閲嶅涓婁竴涓?浣溿偮犅犅犅犅犅犅犅犅犅?/p> 銆銆<<鎶婂綋鍓嶈縐誨埌宸﹁竟銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆>>鎶婂綋鍓嶈縐誨埌鍙寵竟銆偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄敤浜庢枃浠朵腑鎷瘋礉鏂囨湰鐨勫瓧鍛戒護錛毬犅犅犅犅犅犅犅犅犅?/p> 銆銆p聽灝嗙紦鍐插尯鍐呭鍙栧埌鍏夋爣鎵鍦ㄨ鐨勪笅闈竴琛屻偮犅犅犅犅犅犅犅犅犅?/p> 銆銆P聽灝嗙紦鍐插尯鍐呭鍙栧埌鍏夋爣鎵鍦ㄨ鐨勪笂闈竴琛屻偮犅犅犅犅犅犅犅犅犅?/p> 銆銆"bd聽灝嗘枃鏈垹闄よ嚦鏈夊悕緙撳啿鍖篵聽.聽聽聽聽聽聽聽聽聽聽 銆銆"bp聽寮犺創鏈夊悕緙撳啿鍖篵涓唴瀹廣偮犅犅犅犅犅犅犅犅犅?/p> 銆銆yy鎶婂綋鍓嶈鏀懼叆緙撳啿鍖恒偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Y聽鎶婂綋鍓嶈鏀懼叆緙撳啿鍖恒偮犅犅犅犅犅犅犅犅犅?/p> 銆銆Yw鎶婂厜鏍囨墍鍦ㄧ殑鍗曡瘝鏀懼叆緙撳啿鍖恒偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄敤浜庝繚瀛樻枃浠剁殑瀛愬懡浠わ細聽聽聽聽聽聽聽聽聽聽 銆銆:w聽鍥炲啓淇敼鍚庣殑鏂囦歡銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆:w聽filename聽褰揻ilename涓嶅瓨鍦ㄦ椂錛屾妸淇敼鍚庣殑鏂囦歡瀛樹負鏂囦歡filename聽,褰撴枃浠秄ilename聽 銆銆!w聽filename聽濡傛灉鏂囦歡filename瀛樺湪鏃訛紝鎶婁慨鏀瑰悗鐨勬枃浠朵繚瀛樹負鏂囦歡filename聽.聽 涓嬮潰鍒楀嚭浜嗗湪vi緙栬緫鐨勫涓枃浠朵箣闂村垏鎹㈡墍鐢ㄧ殑瀛愬懡浠わ細聽聽聽聽聽聽聽聽聽聽 銆銆:n寮濮嬬紪杈憊i嬋媧葷殑鏂囦歡鍒楄〃涓殑涓嬩竴涓枃浠躲偮犅犅犅犅犅犅犅犅犅?/p> 銆銆:n聽filenames聽鎸囧畾灝嗚緙栬緫鐨勬柊鐨勬枃浠跺垪琛ㄣ偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鍒楀嚭浜嗙敤浜庡湪褰撳墠鏂囦歡鍜屽彟澶栦竴涓枃浠墮棿鍒囨崲鐨勫瓙鍛戒護錛毬犅犅犅犅犅犅犅犅犅?/p> 銆銆:e聽filename聽浣跨敤filename嬋媧籿i聽錛堝湪vi涓鍏ュ彟涓涓枃浠秄ilename錛夈偮?/p> 銆銆e!閲嶆柊瑁呭叆褰撳墠鏂囦歡錛岃嫢褰撳墠鏂囦歡鏈夋敼鍔紝鍒欎涪寮冧互鍓嶇殑鏀瑰姩銆偮犅犅犅犅犅犅犅犅犅?/p> 銆銆:e+filename聽浣跨敤filename嬋媧籿i聽,騫朵粠鏂囦歡灝鵑儴寮濮嬬紪杈戙偮?/p> 銆銆:e+number聽filename聽浣跨敤filename嬋媧籿i聽,騫跺湪絎琻umber琛屽紑濮嬬紪杈戙偮?/p> 銆銆:e#聽寮濮嬬紪杈戝彟澶栦竴涓枃浠躲偮犅犅犅犅犅犅犅犅犅?/p> 涓嬮潰鏄湪鏈枃浠朵腑鍔犲叆鍏朵粬鏂囦歡浠g爜鎵浣跨敤鐨勫瓙鍛戒護錛毬犅犅犅犅犅犅犅犅犅?/p> 銆銆:r聽filename璇誨彇filename鏂囦歡錛屽茍灝嗗叾鍐呭鍔犲埌褰撳墠鏂囦歡鍚庛偮犅犅?/p> 銆銆:r聽!聽command鎵цcommand鏂囦歡錛屽茍灝嗗叾杈撳嚭鍔犲埌褰撳墠鏂囦歡鍚庛偮犅犅?/p> 涓嬮潰鏄痸i涓叾浠栫殑瀛愬懡浠わ細聽聽聽聽聽聽聽聽聽聽 銆銆ctrl+g聽鍙栧緱姝e湪緙栬緫鏂囦歡鐨勬湁鍏充俊鎭偮犅犅犅犅犅犅犅犅犅?/p> 銆銆:sh鍚姩sh聽錛屼粠sh涓繑鍥炲彲鐢╡xit鎴朿trl+d聽.聽聽聽聽聽聽聽聽聽聽 銆銆:!聽Command聽鎵ц鍛戒護command聽.聽聽聽聽聽聽聽聽聽聽 銆銆!!閲嶆柊鎵ц涓婃鐨?!聽Command瀛愬懡浠ゃ偮犅犅犅犅犅犅犅犅犅?/p> 銆銆:q閫鍑簐i聽錛岃嫢鐢ㄦ埛瀵圭紪杈戠殑鏂囦歡鏈夋墍淇敼錛岀郴緇熶笉浼氳鐢ㄦ埛浣跨敤q鍛戒護閫鍑恒偮犅犅?/p> 銆銆:q!閫鍑簐i鑰屼笉綆℃槸鍚﹀鏂囦歡鏈夋敼鍔ㄣ偮犅犅犅犅犅犅犅犅犅?/p> 銆銆ZZ鎴?wq聽淇濆瓨瀵規枃浠剁殑淇敼騫墮鍑簐i聽.聽聽聽聽聽聽聽聽聽聽 銆銆鐢ㄦ埛鍙湪涓涓壒孌婄殑鏂囦歡.exrc涓畾涔夌壒孌婄殑vi鍛戒護銆傚湪vi涓嬌鐢ㄨ繖浜涘懡浠ゆ椂錛屽繀欏誨湪璇ヂ?br />鍛戒護鍓嶅姞涓婁竴涓啋鍙?聽錛?聽銆?/p> <appender name="file" class="org.apache.log4j.RollingFileAppender"> <appender name="error" class="org.apache.log4j.RollingFileAppender"> <logger name="biz.startup"> <logger name="com.aspire" additivity="false"> ***********聽 log4j 閰嶇疆鏂囦歡緇撴潫 ************ **********聽 媧劇敓鐨凾imeSizeRollingFileAppender綾?**** import org.apache.log4j.FileAppender; public class TimeSizeRollingFileAppender 聽 private final static String FS = System.getProperty("file.separator"); ********** TimeSizeRollingFileAppender 綾葷粨鏉?****** ************ 璋冪敤紺轟緥 TestLog4j綾?************** import org.apache.log4j.Logger; public class TestLog4j { 聽 public static void config(){ ***************聽 TestLog4j end ***********
涓浜涜祫鏂?
http://www.csdn.net/subject/j2meTools/
http://news.csdn.net/news/newstopic/24/24127.shtml
]]>
]]>
涓嬮潰鏄嚜鍛戒護妯″紡涓嬫墽琛岀殑錛屽湪鍚屼竴琛屼笂縐誨姩鐨勮嚜鍛戒護錛毬犅犅犅犅犅犅犅犅犅?/p>
瀛樺湪鏃訛紝鎶ラ敊銆偮?/p>
聽聽聽 <1>鎵鏈夌殑鏃ュ織淇℃伅閮借緭鍑哄埌log.log.
聽聽聽 <2>瀵逛簬涓浜涚壒孌婄殑鏃ュ織錛堝鍚姩鏃跺欑殑鏃ュ織錛夛紝杈撳嚭鍒發og/startup/startup.log.
聽聽聽 <3>瀵逛簬鏌愪簺鐗規畩鍖呬笅闈㈢殑鏃ュ織錛屽com.aspire鍖呬笅闈㈢殑error淇℃伅閮借緭鍑哄埌error.log聽聽聽
聽聽聽 鏈変簡榪欏嚑涓姛鑳斤紝鐩鎬俊瀵逛簬澶ч儴鍒嗙殑緋葷粺閮芥槸澶熺敤鐨勪簡錛屼笅闈㈣繖涓緥瀛愬氨鏄疄鐜頒簡榪欏嚑涓姛鑳?
聽聽聽 (鑷充簬鍏朵粬鐨勪竴浜涢厤緗紝濡傛牸寮忚繖浜涚殑灝變笉璇存槑,鏈夊緢澶氳繖縐嶈祫鏂?
聽聽聽
聽聽聽 ***********聽 log4j 閰嶇疆鏂囦歡聽 ************聽聽聽
聽聽聽
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="
聽<param name="File" value="log.log"/>
聽<layout class="org.apache.log4j.PatternLayout">
聽<param name="ConversionPattern" value=" %d{ISO8601} [%c]- %m%n"/>
聽</layout>
</appender>
聽聽<param name="File" value="error.log"/>
聽聽<param name="MaxBackupIndex" value="300"/>
聽聽<param name="Encoding" value="GB2312"/>
聽聽<param name="MaxFileSize" value="20MB"/>
聽聽<layout class="org.apache.log4j.PatternLayout">
聽聽聽<param name="ConversionPattern" value="%d{ISO8601} %p [%c] - [%m]%n"/>
聽聽</layout>
聽聽聽 <filter class="org.apache.log4j.varia.LevelRangeFilter">
聽聽<!-- 榪囨護,鍙褰昬rror淇℃伅-->
聽聽<param name="LevelMin" value="error"/>
聽聽<param name="LevelMax" value="error"/>
聽聽<param name="acceptOnMatch" value="true"/>
聽聽聽 </filter>
</appender>
<appender name="startup" class="com.aspire.TimeSizeRollingFileAppender">
聽聽<!--璇ョ被浣胯嚜宸變粠FileAppender媧劇敓錛屽彲浠ヨ嚜宸辨帶鍒惰緭鍑烘枃浠剁殑璺緞 -->
聽聽<param name="File" value="log/startup/startup.log" />
聽聽<param name="Encoding" value="GBK" />
聽聽<layout class="org.apache.log4j.PatternLayout">
聽聽聽<param name="ConversionPattern" value="%m %d{ISO8601}- %m%n %p %l%n" />
聽聽</layout>
</appender>
<!--Logger logger = Logger.getLogger("biz.startup") 鍙互榪欐牱鏉ヨ皟鐢ㄦ湰logger-->
聽聽<level value="debug" />
聽聽<appender-ref ref="startup" />
</logger>
<!--Log log = LogFactory.getLog(TestLog4j.class) 姝ゆ椂濡傛灉TestLog4j
聽聽聽 浣嶄簬com.aspire鍖呬笅闈紝閭d箞浣跨敤鏈琹ogger
聽-->
聽聽<level value="debug"/>
聽聽<appender-ref ref="error"/>
</logger>
<root>
<level value="info"/>
<!-- 榛樿杈撳嚭鍒發og.log-->
<appender-ref ref="file"/>
</root>
</log4j:configuration>
package com.aspire;
import org.apache.log4j.spi.ErrorCode;
import java.io.File;
import java.io.IOException;
聽聽聽 extends FileAppender
聽聽聽 implements ErrorCode {
聽 public TimeSizeRollingFileAppender() {
聽 }
聽 public void setFile(String file) {
聽聽聽 String val = file.trim();
聽聽聽 File domain = new File(".");
聽聽聽 try {
聽聽聽聽聽 fileName = domain.getCanonicalPath() + FS + val;
聽聽聽 }
聽聽聽 catch (IOException ex) {
聽聽聽聽聽 ex.printStackTrace();
聽聽聽 }
聽 }
}
package com.aspire;
import org.apache.log4j.LogManager;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.xml.DOMConfigurator;
import org.apache.commons.logging.Log;
聽 private Logger logger = Logger.getLogger("biz.startup");
聽 private Log log = LogFactory.getLog(TestLog4j.class);
聽聽聽 DOMConfigurator.configure("conf\\log4jConf.xml");
聽 }
聽 public void Test(){
聽聽聽 /**
聽聽聽聽 * error > warn > info > debug
聽聽聽聽 */
聽聽聽 logger.error("*****error*****");
聽聽聽 logger.debug("****debug*****");
聽聽聽 logger.warn("*****warn******");
聽聽聽 logger.info("*****info******");
聽聽聽 log.error("涓崕涔嬪礇璧?");
聽 }
聽 public static void main(String [] argv){
聽聽聽 TestLog4j t = new TestLog4j();
聽聽聽 TestLog4j.config();
聽聽聽 t.Test();
聽 }
}
]]>
闇瑕佽楄垂杈冮暱鐨勬椂闂存垨璧勬簮錛岃繖縐嶆儏鍐典笅錛屾垜浠彲浠ヨ冭檻浣跨敤Prototype妯″紡銆傛垜瑙夊緱榪欑妯″紡瀹炵敤浜庤繖鏍風殑鎯呭喌:濡傛灉璇ョ被鐨勭敤鎴峰浜庤
綾葷殑瀵硅薄鏄庝箞鍒涘緩鐨勶紝瀵圭被鐨勫唴閮ㄧ粨鏋勮繖浜涢兘涓嶅叧蹇冪殑鎯呭喌錛屽茍涓旇綾葷殑鍒涘緩榪囩▼姣旇緝璐規椂鎴栬祫婧愭椂錛屽彲浠ヨ冭檻浣跨敤璇ユā寮忋備笅闈㈡槸璇ユā寮忕殑
涓涓緥瀛?
Prototype 綾?/font>
package com.moonsoft;
import java.lang.Cloneable;
public class Prototype implements Cloneable {
聽
聽public String myname;
聽
聽Prototype(){
聽聽System.out.println("start:"+System.currentTimeMillis());
聽聽for( int i=0; i< 9999999; i++){聽聽聽
聽聽}
聽聽System.out.println("end:"+System.currentTimeMillis());
聽}
聽
聽public Object clone(){
聽聽Object o = null;
聽聽try{
聽聽聽o = super.clone();聽聽聽
聽聽}
聽聽catch(CloneNotSupportedException ex){
聽聽聽ex.printStackTrace();
聽聽}
聽聽return o;
聽}
聽
聽public void whoami(){
聽聽System.out.println(myname);
聽}
}
嫻嬭瘯綾?br />
package com.moonsoft;
public class Test {
聽
聽public static void main(String [] argv){
聽聽Prototype聽 p = new Prototype();
聽聽p.whoami();
聽聽p.myname = "loucy";
聽聽Prototype聽 p1 = (Prototype)p.clone();
聽聽p1.whoami();聽
聽聽
聽}
}
public class WebServer {
聽
聽public static void main(String[] argv) throws IOException {
聽聽ServerSocket servSocket = new ServerSocket(StringUtil.LISTENING_PORT);
聽聽try {
聽聽聽while (true) {
聽聽聽聽Socket socket = servSocket.accept();
聽聽聽聽new SocketThread(socket).start();
聽聽聽}
聽聽} finally {
聽聽聽servSocket.close();
聽聽}
聽}
}
---SocketThread------
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Writer;
import java.net.Socket;
public class SocketThread extends Thread {
聽private Socket socket = null;
聽public SocketThread(Socket s) {
聽聽this.socket = s;
聽}
聽public void run() {
聽聽try {
聽聽聽if (socket == null) {
聽聽聽聽throw new Exception("==>SOCKET涓虹┖<==");
聽聽聽}
聽聽聽BufferedReader reader = new BufferedReader(new InputStreamReader(
聽聽聽聽聽socket.getInputStream()));
聽聽聽String fileName = "";
聽聽聽while (true) {
聽聽聽聽String str = reader.readLine();
聽聽聽聽if (str == null || str.length() <= 0) {
聽聽聽聽聽break;
聽聽聽聽}
聽聽聽聽//System.out.println("===>"+str);
聽聽聽聽if (StringUtil.isGetRequestInfo(str)) {
聽聽聽聽聽fileName = StringUtil.getFileName(str);
聽聽聽聽聽break;
聽聽聽聽}
聽聽聽}
聽聽聽//System.out.println("===>瀹㈡埛鏈篒P==>"+socket.getInetAddress().toString());
聽聽聽//System.out.println("===>瀹㈡埛鏈虹鍙?=>"+socket.getPort());聽聽聽
聽聽聽/*
聽聽聽 BufferedWriter writer = new BufferedWriter(new
聽聽聽 OutputStreamWriter(socket.getOutputStream()));
聽聽聽 */
聽聽聽PrintStream outputStream = new PrintStream(socket.getOutputStream());
聽聽聽File file = new File(StringUtil.WEBPATH + fileName);
聽聽聽if (file.exists()) { //濡傛灉鏂囦歡瀛樺湪
聽聽聽聽StringUtil.sendHttpHead(outputStream, file);
聽聽聽聽StringUtil.sendFile(outputStream, file);
聽聽聽聽outputStream.flush();
聽聽聽} else { //鏂囦歡娌℃壘鍒幫紝榪斿洖404欏甸潰
聽聽聽聽StringUtil.send404Page(outputStream);
聽聽聽聽outputStream.flush();
聽聽聽}
聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽} finally {
聽聽聽try {
聽聽聽聽socket.close();
聽聽聽} catch (Exception e) {
聽聽聽}
聽聽}
聽}
}
---StringUtil-----
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintStream;
/**
聽* @author xiaoliang
聽*/
public class StringUtil {
聽// 鏈嶅姟鍣ㄧ洃鍚殑绔彛
聽public static final int LISTENING_PORT = 8080;
聽// 鏈嶅姟鍣ㄦ枃浠剁殑浣嶇疆
聽public static final String WEBPATH = "E:";
聽/**
聽 * 鍒ゆ柇璇ュ瓧絎︿覆鏄笉鏄祻瑙堝櫒鍙戦佽繃鏉ョ殑璇鋒眰澶翠俊鎭?br />聽 * @param str
聽 * @return
聽 */
聽public static boolean isGetRequestInfo(String str) {
聽聽if (str == null || str.length() <= 0)
聽聽聽return false;
聽聽boolean isGetStr = true;
聽聽if (str.indexOf("GET") != 0) {
聽聽聽isGetStr = false;
聽聽}
聽聽if (str.indexOf("HTTP/") <= 0) {
聽聽聽isGetStr = false;
聽聽}
聽聽return isGetStr;
聽}
聽/**
聽 * 鑾峰緱璇鋒眰淇℃伅涓殑鏂囦歡鍚?榛樿涓篿ndex.html
聽 *
聽 * @param str
聽 * @return
聽 */
聽public static String getFileName(String str) {
聽聽String fileName = "index.html", s;
聽聽int httpIndex = str.lastIndexOf("HTTP/");
聽聽s = str.substring(3, httpIndex);
聽聽s = s.trim();
聽聽if (s != null && s.length() > 0 && s.indexOf(".") > 0) {
聽聽聽fileName = s;
聽聽}
聽聽return fileName;
聽}
聽/**
聽 * 鍙戦佹枃浠跺埌瀹㈡埛绔?br />聽 *
聽 * @param out
聽 * @param file
聽 */
聽public static void sendFile(PrintStream out, File file) {
聽聽try {
聽聽聽DataInputStream in = new DataInputStream(new FileInputStream(file));
聽聽聽int length = (int) file.length();
聽聽聽byte[] buffer = new byte[length];
聽聽聽in.readFully(buffer);
聽聽聽out.write(buffer, 0, length);
聽聽聽in.close();
聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽}
聽}
聽/**
聽 * 鍙戦佽繑鍥炵殑澶撮儴淇℃伅
聽 * @param out
聽 */
聽public static void sendHttpHead(PrintStream outputStream, File file) {
聽聽try {
聽聽聽outputStream.println("HTTP/1.0200OK");
聽聽聽outputStream.println("Content_Type:text錛廻tm1");
聽聽聽outputStream.println("Content_Length:" + file.length());
聽聽聽outputStream.println("Server:moon webserver 1.0");
聽聽聽outputStream.println("");
聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽}
聽}
聽/**
聽 * 榪斿洖404欏甸潰
聽 * @param out
聽 */
聽public static void send404Page(PrintStream out) {
聽聽try {
聽聽聽out.println("HTTP 錛?.0 404 no found");
聽聽聽out.println("Content_type:text/html");
聽聽聽out.println("");
聽聽聽out.println("Error404:file not found!");
聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽}
聽}
聽
聽public static void main(String[] argv) {
聽聽String str = "GET /11.html HTTP/1.1";
聽聽str = StringUtil.getFileName(str);
聽聽System.out.println("==>" + str + "<==");
聽聽File file = new File(StringUtil.WEBPATH + str);
聽聽if (file.exists()) {
聽聽聽System.out.println("exists");
聽聽} else {
聽聽聽System.out.println("not exists");
聽聽}
聽}
}
3>紺轟緥
//媯鏌ヨ〃鍗曟槸鍚︽紜?BR> boolean isMultipart = FileUpload.isMultipartContent(request);
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
//鏂囦歡鏈澶э紝璁句負-1琛ㄧず涓嶅彈闄愬埗
upload.setSizeMax(4096);
//瑙f瀽璇鋒眰錛屾妸瑙f瀽鐨勭粨鏋滄斁鍦ㄤ竴涓狶ist閲岄潰
List items = upload.parseRequest(request);
//緙撳瓨澶у皬錛岃涓?1琛ㄧず涓嶅彈闄愬埗
factory.setSizeThreshold(4096);
//璁劇疆涓存椂鐩綍
factory.setRepository(new File("D:\\temp"));
Iterator iter = items.iterator();
while( iter.hasNext() ){
FileItem item = (FileItem)iter.next();
//媯鏌ユ槸涓涓櫘閫氱殑琛ㄥ崟鍩熻繕鏄疐ile緇勪歡
if( !item.isFormField() ){
System.out.println("FileName:==>"+item.getName());
System.out.println("FieldName:==>"+item.getFieldName());
System.out.println("Size:==>"+item.getSize());
//item.getName 榪斿洖鐨勬槸瀹屾暣鐨勬枃浠跺悕錛屽:E:\\xx\11.doc
//鎵浠ヨ繖閲岀敤涓涓猣ullFile鏉ュ彇鏂囦歡鍚?BR> File fullFile = new File(item.getName());
File uploadedFile = new File("D:\\ftp\\",fullFile.getName());
item.write(uploadedFile);
}
}
2銆佹湁鐘舵丒JB錛岀被浼兼暟鎹簱鐨凜onnect閾炬帴錛屼篃綾諱技綰跨▼瀹堟姢錛屽畠鎻愪緵寮曠敤姹?Bean instance pool)錛屾瘡涓鎴風浼氭湁鍗曠嫭鐨勪俊鎭?BR>渚嬪錛氬湪鏌愭湁鐘舵丒JB涓紝鏈変竴涓暟鎹垚鍛橈紙鍙橀噺錛?i_count 錛堟暣鍨嬶紝鐢ㄤ簬璁塊棶璁℃暟錛屽垵濮嬪間負0錛岃闂竴嬈$瘡鍔?錛夛紝瀹冨姣忎釜瀹㈡埛绔潵璇存槸闅旂鐨勩傛煇瀹㈡埛绔闂悗錛屽肩瘡鍔犱負1銆傚彟涓涓鎴風璁塊棶鏃惰繕鏄師鏉ョ殑鍊間負0銆?/P>
榪欓噷鎻愬埌鐨勬暟鎹垚鍛橈紙鍙橀噺錛?i_count 錛屽湪EJB瑙勮寖涓О浣滐細conversational state 銆傚瀹冪殑瑕佹眰涔熷緢澶氱殑錛屼緥濡傜被鍨嬩負 Serializable objects銆傝繕鏈夛紝榪樿鍦╡jbActivate()錛宔jbPassivate()錛宔jbRemove()絳夌敓鍛藉懆鏈熺害瀹氱殑鏂規硶涓鐞嗐傝瑙丒JB瑙勮寖鍚с?/P>
鎴戠殑鎰熸兂錛氬湪鐪嬬涓閬嶄功鏃訛紝榪樹竴鐐規劅瑙夐兘娌℃湁錛屾牴鏈氨鐪嬩笉鏄庣櫧SessionBean涓殑session涓嶴ervlet瀹瑰櫒涓殑session鏈変粈涔堝尯鍒?BR>鍔ㄦ墜緙栫▼鍚庯紝鎵嶆劅瑙夊埌EJB鍙槸姣擲ervlet鏇磋鑼冿紝鏇撮噸閲忚屽凡銆傜湡姝g殑鍖哄埆灝辨槸鎺ュ彛鍗忚涓涓槸鍩轟簬HTTP錛屼竴涓槸鍩轟簬RMI/IIOP銆係ervlet涓庢棤鐘舵佺殑SessionBean鍦⊿ession涓婃槸涓鏍風殑鎺у埗銆係ervlet涓殑Session瀵硅薄涓庢湁鐘舵佺殑SessionBean鏄竴鏍風殑鎺у埗銆?BR>瀵逛簬搴旂敤錛屼緥濡傛湁涓涓喘鐗╄濺錛岃璁板綍姝e湪閲囪喘鐨勭墿鍝佷俊鎭紝娌℃湁EJB鏃訛紝鎴戜滑涓鑸槸瀛樺湪Servlet瀹瑰櫒涓殑session涓傛湁浜咵JB錛屽垯鍙互瀛樺偍鍦ㄦ湁鐘舵佺殑SessionBean涓紝騫朵笖璇ユ鏈夌姸鎬佺殑sessionBean鐨刬nstance榪樺緱淇濆瓨鍦⊿ervlet鐨剆ession涓傝繖鏍風殑濂藉鏄細鑷沖皯鍙互鍑忚交Servlet瀹瑰櫒鐨勮礋杞姐?BR>
杞嚜:
http://zengabo.blogchina.com/blog/527365.html