Jim Raynor
Jim Raynor

Reputation: 2268

Make log4j DailyRollingFileAppender roll over date OR size, whichever comes first

I know that log4j provides RollingFileAppender and DailyRollingFileAppender classes, however, DailyRollingFileAppender does not support MaxFileSize property.

How do I tweak the behavior of log4j so that it can log in a way like this: the rolling policy is based on both time period (and file name is appended with DatePattern), like in DailyRollingFileAppender, and MaxFileSize (like in RollingFileAppender)?

Example:

Upvotes: 3

Views: 6745

Answers (2)

espinchi
espinchi

Reputation: 9212

Have a look at the open-source TimeAndSizeRollingAppender in www.simonsite.org.uk, as stated in this answer at another question here at SO.

Upvotes: 0

nayakam
nayakam

Reputation: 4239

You could extend the FileAppender class or any other appender class and implement your custom version. Example
DailyRollingFileAppender

Upvotes: 2

Related Questions