log4j配置

log4j.propertiesweb

log4j.rootCategory=INFO, stdout , D , I , W , E
 
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[testLog] %p [%t] %C.%M(%L) | %m%n

log4j.appender.D=org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File=D:\\TestLogs\\DEBUG.log
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout=org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern=%d-[\u65E5\u5FD7] %p %l - %m%n
 
log4j.appender.I=org.apache.log4j.DailyRollingFileAppender
log4j.appender.I.File=D:\\TestLogs\\INFO.log
log4j.appender.I.Threshold = INFO
log4j.appender.I.layout=org.apache.log4j.PatternLayout
log4j.appender.I.layout.ConversionPattern=%d-[\u65E5\u5FD7] %p %l - %m%n

log4j.appender.W=org.apache.log4j.DailyRollingFileAppender
log4j.appender.W.File=D:\\TestLogs\\WARN.log
log4j.appender.W.Threshold = WARN
log4j.appender.W.layout=org.apache.log4j.PatternLayout
log4j.appender.W.layout.ConversionPattern=%d-[\u65E5\u5FD7] %p %l - %m%n

log4j.appender.E=org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File=D:\\TestLogs\\ERROR.log
log4j.appender.E.Threshold = ERROR
log4j.appender.E.layout=org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern=%d-[\u65E5\u5FD7] %p %l - %m%n

log4j.logger.com.lzy.controller=DEBUG
log4j.logger.com.opensymphony.oscache=ERROR
log4j.logger.net.sf.navigator=ERROR
log4j.logger.org.apache.commons=ERROR
log4j.logger.org.apache.struts=WARN
log4j.logger.org.displaytag=ERROR
log4j.logger.org.springframework=DEBUG
log4j.logger.com.ibatis.db=WARN
log4j.logger.org.apache.velocity=FATAL
 
log4j.logger.com.canoo.webtest=WARN
 
log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN
log4j.logger.org.hibernate=DEBUG
log4j.logger.org.logicalcobwebs=WARN


日誌優先級
level 是日誌記錄的優先級,分爲OFF、FATAL、ERROR、WARN、INFO、DEBUG、ALL或者自定義的級別。Log4j建議只使用四個級別,優先級從高到低分別是ERROR、WARN、INFO、DEBUG。經過在這裏定義的級別,您能夠控制到應用程序中相應級別的日誌信息的開關。好比在這裏定義了INFO級別,只有等於及高於這個級別的才進行處理,則應用程序中全部DEBUG級別的日誌信息將不被打印出來。ALL:打印全部的日誌,OFF:關閉全部的日誌輸出。spring

相關文章
相關標籤/搜索