1. 程式人生 > >關於Log4j的筆記

關於Log4j的筆記

clas 輸出信息 ace 筆記 console bsp pen erro out

log4j的配置

 1 ### 設置-這裏可以控制輸出級別###
 2 log4j.rootLogger = debug,stdout,D,E
 3 
 4 ### 輸出信息到控制擡 ###
 5 log4j.appender.stdout = org.apache.log4j.ConsoleAppender
 6 log4j.appender.stdout.Target = System.out
 7 log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
 8 log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
9 10 ### 輸出DEBUG 級別以上的日誌到=F://JAVA_workspace/workspce_log/log.log ### 11 log4j.appender.D = org.apache.log4j.DailyRollingFileAppender 12 log4j.appender.D.File = F://JAVA_workspace/workspce_log/log.log 13 log4j.appender.D.Append = true 14 log4j.appender.D.Threshold = DEBUG 15 log4j.appender.D.layout = org.apache.log4j.PatternLayout
16 log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n 17 18 ### 輸出ERROR 級別以上的日誌到=F://JAVA_workspace/workspce_log/error.log ### 19 log4j.appender.E = org.apache.log4j.DailyRollingFileAppender 20 log4j.appender.E.File =F://JAVA_workspace/workspce_log/error.log 21 log4j.appender.E.Append = true
22 log4j.appender.E.Threshold = ERROR 23 log4j.appender.E.layout = org.apache.log4j.PatternLayout 24 log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

關於Log4j的筆記