寫一個(gè)log4j的properties文件,再在web.xml里面配置一下就ok了,你參考下吧
創(chuàng)新互聯(lián)建站是一家集網(wǎng)站建設(shè),巴林左旗企業(yè)網(wǎng)站建設(shè),巴林左旗品牌網(wǎng)站建設(shè),網(wǎng)站定制,巴林左旗網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,巴林左旗網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d]-%-5p %t (%C.%M:%L) | %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=e:/Logs/PB/root.log
log4j.appender.file.MaxFileSize=5000KB
log4j.appender.file.MaxBackupIndex=5
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%d]-%-5p %t | %m%n
log4j.logger.java.sql = DEBUG,ibatis
log4j.additivity.java.sql=false
log4j.logger.java.sql.Connection = DEBUG
log4j.logger.java.sql.Statement = DEBUG
log4j.logger.java.sql.PreparedStatement = DEBUG
log4j.logger.java.sql.ResultSet = DEBUG
log4j.logger.com.ibatis = DEBUG,ibatis
log4j.additivity.com.ibatis=false
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate = DEBUG
log4j.logger.com.ibatis.sqlmap.engine.cache.CacheModel=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientImpl=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.builder.xml.SqlMapParser=DEBUG
log4j.logger.com.ibatis.common.util.StopWatch=DEBUG
log4j.appender.ibatis=org.apache.log4j.RollingFileAppender
log4j.appender.ibatis.File=e:/Logs/PB/ibatis.log
log4j.appender.ibatis.MaxFileSize=5000KB
log4j.appender.ibatis.MaxBackupIndex=5
log4j.appender.ibatis.Threshold=DEBUG
log4j.appender.ibatis.layout=org.apache.log4j.PatternLayout
log4j.appender.ibatis.layout.ConversionPattern=[%d]%m%n
log4j.rootLogger=DEBUG,stdout,file
log4j.logger.org.springframework=INFO
log4j.logger.org.displaytag=INFO
log4j.logger.freemarker=INFO
log4j.logger.com.opensymphony.xwork2=INFO
log4j.logger.com.pracbiz=DEBUG
配置文件設(shè)置如下:
log4j.rootLogger=debug,stdout,logfile??
log4j.appender.stdout=org.apache.log4j.ConsoleAppender??
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout??
log4j.appender.stdout.layout.ConversionPattern=%5p?[%t]?(%F:%L)?-?%m%n??
log4j.appender.logfile=org.apache.log4j.RollingFileAppender??
log4j.appender.logfile.File=logfile.log??
log4j.appender.logfile.MaxFileSize=512KB??
log4j.appender.logfile.MaxBackupIndex=3??
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout??
log4j.appender.logfile.layout.ConversionPattern=%d?%p?[%c]?-?%m%n
測(cè)試java?文件
log4j.rootLogger=debug,stdout,logfile??
log4j.appender.stdout=org.apache.log4j.ConsoleAppender??
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout??
log4j.appender.stdout.layout.ConversionPattern=%5p?[%t]?(%F:%L)?-?%m%n??
log4j.appender.logfile=org.apache.log4j.RollingFileAppender??
log4j.appender.logfile.File=logfile.log??
log4j.appender.logfile.MaxFileSize=512KB??
log4j.appender.logfile.MaxBackupIndex=3??
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout??
log4j.appender.logfile.layout.ConversionPattern=%d?%p?[%c]?-?%m%n
如果是小程序就不是必須的了
如果是大點(diǎn)的程序,日志就非常有用了
日志的作用,主要在維護(hù)的時(shí)候非常有用,系統(tǒng)可能會(huì)出一些其名其秒的錯(cuò)誤,這個(gè)時(shí)候如果日志做的比較詳細(xì)就能很清楚的查找到錯(cuò)誤了~~
1.用eclipse等開(kāi)發(fā)工具的話,日志會(huì)在控制臺(tái)輸出!
2.web項(xiàng)目的話,在容器里面可以找到,如:tomcat,jBoss等
3 log4j的話,在配置文件中指定的是哪里,就是哪里