views:

367

answers:

2

With log4j, I want the behaviour of the DailyRollingFileAppender so that date-pattern based log rolling can occur when an application starts up. BUT once the application has started, I don't want it to do any automatic log rotation until the next time the application restarts. How can I configure log4j to do this?

+1  A: 

You will have to programatically set the logger properties by iterating over all the loggers, getting your logger and then asking ti not to roll anymore. Thats the only way I think.

Gaurav
+1  A: 

Your specification sounds like you want the application to start, create a log file of a particular date, and to keep using that until it shuts down.

If that's the case, you may want to create your own Appender implementation, perhaps deriving from FileAppender

Brian Agnew