问题
Is there any configuration by which I can create datewise log files, I mean to say everyday a new file should be created.
回答1:
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
来源:https://stackoverflow.com/questions/9091592/datewise-log-files-using-log4j