log4j分包打印log、分级别打印log,打印到包的不同文件

log4j.rootLogger=error,stdout,D,  E, F, G
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n


#企业库logstar
log4j.logger.com.leo.company=info,company
log4j.appender.company=org.apache.log4j.DailyRollingFileAppender
log4j.appender.company.File = D:/logs/leo/company/log.log
log4j.appender.company.Encoding = UTF-8
log4j.appender.company.DatePattern = '_'yyyy-MM-dd'.log'
log4j.appender.company.Append = true
log4j.appender.company.Threshold = INFO
log4j.appender.company.layout = org.apache.log4j.PatternLayout
log4j.appender.company.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n
#企业库logend


### 保存DEBUG信息到单独文件 ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = D:/logs/leo/debug/debug_log.txt
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %c:%r ] - [ %p ]  %m%n
log4j.appender.D.MaxBackupIndex=10


### 保存INFO信息到单独文件 ###
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File = D:/logs/leo/info/info_log.txt
log4j.appender.E.Append = true
log4j.appender.E.Threshold = INFO
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n
log4j.appender.E.MaxBackupIndex=10


### 保存WARN信息到单独文件 ###
log4j.appender.F = org.apache.log4j.DailyRollingFileAppender
log4j.appender.F.File = D:/logs/leo/warn/warn_log.txt
log4j.appender.F.Append = true
log4j.appender.F.Threshold = WARN
log4j.appender.F.layout = org.apache.log4j.PatternLayout
log4j.appender.F.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n
log4j.appender.F.MaxBackupIndex=10


### 保存ERROR信息到单独文件 ###
log4j.appender.G = org.apache.log4j.DailyRollingFileAppender
log4j.appender.G.File = D:/logs/leo/error/error_log.txt
log4j.appender.G.Append = true
log4j.appender.G.Threshold = ERROR
log4j.appender.G.layout = org.apache.log4j.PatternLayout
log4j.appender.G.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n
log4j.appender.G.MaxBackupIndex=10

你可能感兴趣的:(练习)