• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Rolling Tomcat Logs

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 75
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic