I have configured tomcat 7 to use log4j(1.2 version) to generate server and application logs. Application and server logs are being appended to catalina.out.
Also configured DailyRolllingAppender to rotate catalina.out. There seems some problem during rotating catalina.out and the backupd log contains next day log.
i.e backup of 22 contains 23rd log. To test and verify the behavior, created an another appender that logs to server.log. This rotates properly. Seems log name catalina.out is being used internal by tomcat.
Do you have any idea, what could be the cause?
One thing that Tomcat's documentation doesn't make very clear is how it works with logging. Tomcat itself logs via the java.util.logging package (JULI) and normally the log messages are going to stdout, which is typically written to catalina.out. You cannot simply "configure" Tomcat to log itself via log4j, you have to build a custom Tomcat according to their directions with Log4j selected in the Tomcat build process. You may have done all this, but since you just said "configured", I wanted to make sure you knew.
The logs for each of the webapps are distinct and separate from all of the other webapps - and from Tomcat itself. So to get a unified log on catalina.out, those various log4j sources have to all aim at a common target. Since the catalina.out file is simply the Tomcat JVM's stdout, it's not suitable for use with a rolling log appender - you'd have to externally rotate it, and one of the problems with rotating stdout is that you're pretty much limited to restarting the JVM - Tomcat, webapps, and all - in order to do it.
On the other hand, rotating to a non-stdio file via a rolling appender is messy, since you have potential fights between the server and apps on which one will do the actual rolling.
One way around this is to log to a data channel, such as a network logging pipeline and let whatever sits on the other end of that pipeline worry about rolling the logs.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Aug 23, 2012
I did all the configuration as per the tomcat site by taking jars from extras component. Right now my web application and server logs goes to catalina.out.
Didn't understand your last option i.e log to data channel.
Joined: Aug 23, 2012
One more behavior i see is that, when i restart the tomcat, it rotates the logs. Is there a way to specify in tomcat not to do rotation on startup.