简体   繁体   中英

Datewise log files using Log4j

是否可以通过任何配置创建按日期排列的日志文件,我的意思是说每天都应该创建一个新文件。

Use DailyRollingFileAppender http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html

log4j.appender.P=org.apache.log4j.DailyRollingFileAppender
log4j.appender.P.File=c:/log/log.txt
log4j.appender.P.Append=true
log4j.appender.P.DatePattern='.'yyy-MM-dd
log4j.appender.P.layout=org.apache.log4j.PatternLayout
log4j.appender.P.layout.ConversionPattern=%d{MM-dd HH:mm:ss.S} %t %m%n

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM