log4j每天生成一个文件配置

log4j.rootLogger=INFO,CONSOLE,logDailyFile

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p [%t] %c{1} - %m%n

log4j.logger.com.shankephone.mi=DEBUG

#按DatePattern输出到文件
log4j.appender.logDailyFile= org.apache.log4j.DailyRollingFileAppender
log4j.appender.logDailyFile.layout= org.apache.log4j.PatternLayout
log4j.appender.logDailyFile.layout.ConversionPattern= [%-5p][%-22d{yyyy/MM/dd HH:mm:ssS}][%l]%n%m%n
log4j.appender.logDailyFile.Threshold= DEBUG
log4j.appender.logDailyFile.ImmediateFlush= TRUE
log4j.appender.logDailyFile.Append= TRUE
#开发
log4j.appender.logDailyFile.File= D:/home/mi2/logs/mi.log
#测试
#log4j.appender.logDailyFile.File= /home/mi2/logs/mi.log
#生产
#log4j.appender.logDailyFile.File= D:/home/mi2/logs/mi.log
log4j.appender.logDailyFile.DatePattern= -yyyy-MM-dd'.log'
log4j.appender.logDailyFile.Encoding= UTF-8

效果如下:

 

posted @ 2019-09-03 14:34  恋在那时  阅读(1440)  评论(0编辑  收藏  举报