aspose file tools*
The moose likes Tomcat and the fly likes Rolling Tomcat Logs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Rolling Tomcat Logs " Watch "Rolling Tomcat Logs " New topic
Author

Rolling Tomcat Logs

Aparna Sree
Greenhorn

Joined: Jul 21, 2010
Posts: 28
Hi,

I am using Tomcat7. I have an application which internally uses another 3rd party tool which has logs in the form of sysouts.
I am using log4j for my application which rotates and archives logs properly.

But I want to implement the same for the tomcat logs also. i.e sysout logs. After little research I figured out that by modifying logging.properties file in <tomcat-home>\conf , logs will be rotated every day.
Is there any way to achieve size based rotation and archiving for sysouts?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Sysout, by definition, outputs to the JVM stdout and stderr I/O channels. Stdout is expected to be a continuous data stream. The only way to route it to rolling files is to first redirect stdout to a file (since the default destination is to the console), then when you want to roll it, stop Tomcat and its JVM, re-assign the stdout channel to a new file, and restart Tomcat. Re-routing of stdout on the fly is not a "write once/run anywhere" capability, so there is no support in pure Java. Stderr operates identically.

Just for info, the most common Tomcat run scripts redirect the JVM stdout to its logs/catalina.out file. Some people do shut down Tomcat daily and rename this file in order to roll logs.


Customer surveys are for companies who didn't pay proper attention to begin with.
Aparna Sree
Greenhorn

Joined: Jul 21, 2010
Posts: 28
Thank you for the reply.
Just for info, the most common Tomcat run scripts redirect the JVM stdout to its logs/catalina.out file


I was just wondering how will redirecting stdout to catalina.out help?
I am using tomcat 7 on windows 7

One more thing is
But I want to implement the same for the tomcat logs also. i.e sysout logs. After little research I figured out that by modifying logging.properties file in <tomcat-home>\conf , logs will be rotated every day.


sysout will not rotate every day. Other logs like rotate catalina.log,localhost.log, manager.log and host-manager will.
K. Gil
Ranch Hand

Joined: Apr 29, 2011
Posts: 75

This is a little bit peoblematic, to be honest.

How do I rotate catalina.out?
http://wiki.apache.org/tomcat/FAQ/Logging#Q10

That what I would suggest is to use log4j, and if for some reason your catalina.out will grow up quickly as well, alter startup script, so it rotate log and use new fresh log file on every start/restart.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rolling Tomcat Logs