File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes How to roll over catalina.out in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to roll over catalina.out in tomcat" Watch "How to roll over catalina.out in tomcat" New topic
Author

How to roll over catalina.out in tomcat

Princy Mathew
Greenhorn

Joined: Sep 11, 2007
Posts: 6
Catalina.out files in my tomcat are growing very large and taking up a lot of room. Would there be a way to restrict the size of them either by size or date maybe two weeks?

Thanks
Princy
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Logging seems to be one of the things that changes quite a bit from release to release in Tomcat.
Which version are you using?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Princy Mathew
Greenhorn

Joined: Sep 11, 2007
Posts: 6
Im using Tomcat 5.0

Thanks
princy
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you plan on upgrading any time soon, you might want to hold off on doing anything with logging.
The mechanism in 5.0 has been deprecated.

Here is the page explaining this.
http://tomcat.apache.org/tomcat-5.0-doc/config/logger.html


Personally, I went with log4j, configured in my own app.
Once I did this, Tomcat didn't have much to log and the catalina.out stayed small enough that there was no need to manage it on a constant basis.
[ September 12, 2007: Message edited by: Ben Souther ]
Princy Mathew
Greenhorn

Joined: Sep 11, 2007
Posts: 6
I got an information that if we set the swallowOutput attribute as true for all web application contexts in server.xml , the output will go to the Logger that's defined at the level of each context. Then, by default, the Logger will roll nightly.

SO is there any way to automatically delete(after certain period or after certain size ) these log files that are created every day.

Thanks
princy
Princy Mathew
Greenhorn

Joined: Sep 11, 2007
Posts: 6
I got an information that if we set the swallowOutput attribute as true for all web application contexts in server.xml , the output will go to the Logger that's defined at the level of each context. Then, by default, the Logger will roll nightly.

SO is there any way to automatically delete(after certain period or after certain size ) these log files that are created every day.

Thanks
princy
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is nothing in Tomcat that deletes log files but it wouldn't be hard to write a shell or batch script that archives (I would never programmatically delete log files) that have last modified dated over n days old.
H. Hall
Greenhorn

Joined: Sep 14, 2007
Posts: 8
As I recall Tomcat will automatically create a new catalina.out file if it cannot find one e.g. if you deleted it. Why not create a cron to rename the file catalina.out with say a suffix of today's date that runs at your desired interval. You could compress it at the same time.

Cheers
Sebastian Leal-Bennett
Greenhorn

Joined: Feb 03, 2008
Posts: 2
Hi - if you're in linux land then you can write a basic shell script and pop it on the cron eg, the one we use to roll the logs and delete old ones is (it leaves 3days of logs for you - still i test, but it looks to work):

1) copy catalina.out to one site and rename it(this will become the archive)
2) clear out catalina.out
3) delete all files over a set age

This script was designed for itterating through a log dir and its sub dirs (hence the use of find) deleting all files over a set age and rolling those that didnt roll themselves.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to roll over catalina.out in tomcat
 
Similar Threads
server log disappear from console
Emptying catalina.out ?
How to clear log files?
HTTP Status 404 problem
how to get System.out.print()