Denis Kulagin
Denis Kulagin

Reputation: 8906

log4j: rotate log, when it's size exceeds defined threshold

We have recently encountered a problem: if external service fails, logs easily become flooded with similar data indicating a problem. In logback problem was solved easily: I've set log size threshold, after which log files were rolled over and zipped.

Is there a similar feature, when using log4j? I need to have a support for both daily rollover and size-threshold rollover.

Upvotes: 1

Views: 225

Answers (1)

sina72
sina72

Reputation: 5101

Hava a look at RollingFileAppender. There is an example that you can base on. An appender for daily rolling is included. You can extend it if you need an additional size threshold, or use the TimeAndSizeRollingAppender from Simon Park.

Upvotes: 1

Related Questions