I am using log4j for creating log files. I used DailyRollingFileAppender to create log files for each day. But I also need to create a new file when the file size exceeds a max limit. RollingFileAppender supports MaxFileSize property, But it doesn't work for DailyRollingFileAppender. What should I do?
Try using DailyRollingFileAppender with below configuration,
log4j.appender.infoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.infoAppender.DatePattern='.' yyyy-MM-dd HH-mm
log4j.appender.infoAppender.Threshold=DEBUG
log4j.appender.infoAppender.File=D:/debug.log
Try making logs per hour. This may not solve your problem completely but will help for sure. DailyRollingFileAppender doesnt support file size.
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.