Hi Ryan, Not sure whether this helps you or not, but the TimeAndSizeRollingAppender has a RollOnStartup switch. This ensures that logs are rolled when the appender receives the first event logged by the application following start-up. Thereafter logs are rolled normally according to the time and/or size constraints that you specify. See my homepage, www.simonsite.org.uk for details.
Best Regards, Simon ________________________________ From: "[email protected]" <[email protected]> To: [email protected] Sent: Wed, 19 May, 2010 18:59:03 Subject: Tomcat Daily Log Rotation fails at app. level. Hi All: *I solved my own issue. Sending to list in hopes it help someone else* This may be more of a Tomcat question... However, I suspect my problem relates to how Log4J is maintaining the state info, for when to rotate the logs. Running on Red Hat ES 5.5 I have Tomcat 6.0.26 configured to use Log4j. This has allowed me to auto rotate the delivered logs: catalina.out.2010-05-16.gz catalina.out.2010-05-17.gz catalina.out Works great. We are running a third party web app that has stability issues so we restart Tomcat nightly. The server level log rotation still works. However, when the same setup is applied at the application level the application log fails to rotate *Daily*. During testing rotation works when the FileNamePattern is configured to have the log roll over *inside* of a given day (hourly or every minute). <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> <param name="FileNamePattern" value="${system.logdir}/nolij.log.%d{yyyy-MM-dd-HH}.gz"/> </rollingPolicy> Evidence suggests that Log4J is losing the state of when to roll the application's log due to the server restart. In our devel. environment I disabled the nightly restart and the application's log rotated. What I don't understand is why the Server level log rotation still works but, the app's log does not. Oh.... amazing how putting your thoughts down can sometimes resolve them: I believe, since Log4J determines when to rotate the Log based on the rotation period when a new event is received, it is receiving events during the shutdown and rotating the catalina.out log. However, the application is only used during office hours and never receives an event prior to the restart. The quick fix is to force an event in the application log prior to the restart of Tomcat. Ideally (for my situation anyway) would be for org.apache.log4j.rolling.TimeBasedRollingPolicy code to cache the policy to disk so the state of when to rotate is not lost. Ryan Russo -:- russo (at) albany (dot) edu University at Albany -:- Technical Services Team --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
