Sunday, May 1, 2011

log4j - trigger log rolling when application starts

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?

From stackoverflow
  • 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.

  • 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

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.