• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rolling Tomcat Logs

 
Aparna Sree
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18226
53
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aparna Sree
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic