log4j配置檔案示例

lcz393537415發表於2016-07-11
### set log levels ###
log4j.rootLogger = INFO,D,D1

### \u8F93\u51FA\u5230\u63A7\u5236\u53F0 ###
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{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n

### \u8F93\u51FA\u5230\u65E5\u5FD7\u6587\u4EF6 ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
#log4j.appender.D.File = D:/logs/log.log
log4j.appender.D.File =/data/ecc/logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = INFO
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n

### \u4FDD\u5B58\u5F02\u5E38\u4FE1\u606F\u5230\u5355\u72EC\u6587\u4EF6 ###
log4j.appender.D1 = org.apache.log4j.DailyRollingFileAppender
#log4j.appender.D1.File = D:/logs/error.log
log4j.appender.D1.File =/data/ecc/logs/error.log
log4j.appender.D1.Append = true
log4j.appender.D1.Threshold = ERROR
log4j.appender.D1.layout = org.apache.log4j.PatternLayout
log4j.appender.D1.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31347383/viewspace-2121852/,如需轉載,請註明出處,否則將追究法律責任。

相關文章