views:

370

answers:

1

i am trying to rotate the log file everyday by using the DailyRollingFileAppender, but i have a problem: the log files are not updated everyday, so it doesn't get rotate when there is no new stuff in it.

is there a way in the log4j.properties that i can set it so that log4j rotate the log file everyday even if the file has no changes?

+2  A: 

Log4j DailyRollingFileAppender will not output an empty file if no logging has occurred. From the implementation:

/**
* This method differentiates DailyRollingFileAppender from its
* super class.
*
* <p>Before actually logging, this method will check whether it is
* time to do a rollover. If it is, it will schedule the next
* rollover time and then rollover.
* */
protected void subAppend(LoggingEvent event) {
Alex B
thanks! it's good to know.
fei