What is the configuration in log4j.xml for rotatin

2019-05-24 11:51发布

Kindly let me know if there is a way to rotate the logfiles based on time as well as size.

The log file is required to be in a format logfilename.log.date when the roll over happens based on time.

标签: java log4j
2条回答
小情绪 Triste *
2楼-- · 2019-05-24 11:59

If you want to do the rotation based on time DailyRollingFileAppender probably is the best practice. You can have yearly, monthly, hourly etc logs based on your configuration.

If you want size based rotation RollingFileAppender could be very useful.

Furthermore, if you want to use both time and size at the same time I would suggest you to take a look at TimeAndSizeRollingAppender, free under the Apache 2.0 license, which claims to be providing full features of both DailyRollingFileAppender and RollingFileAppender.

查看更多
登录 后发表回答