This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Tomcat and the fly likes How to clear log files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Reply locked New topic
Author

How to clear log files?

Nitin Jawarkar
Ranch Hand

Joined: Dec 18, 2004
Posts: 79
Hello,

There are log files in /tomcat/logs/ directory what happen whenever i hit page then datewise log file is created and also the size of catalina.out file is increase acoording to hit page, due to this my server take extra space for this, so is there any solution that log file will not generate everytime.

Thanx


Cheers<br />Nitin
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Which file is growing? If it's an access log, then that's what it's supposed to do. If it's catalina.out, std.out, err.out, or something similar, each entry is due to a System.out.println(), e.printStackTrace() or similar in your code. Remove those and the output will stop.

Logging has changed over time in Tomcat. Which version are you using, what OS and, if Windows, is it installed as a service? Also, what exactly are the names of the files in the logs directory.
Answer these and I can probably help you quiet them down.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Nitin Jawarkar
Ranch Hand

Joined: Dec 18, 2004
Posts: 79
thanx,

I m using Tomcat 5.0.27 and OS is windows-98 and files generated are date wise in logs directory means for each date it generate one log file, similar catalina.out size also increase same time so for this what shoul i do to prevent them.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I think the best thing to do in your case is go through the code and get rid of the System.out.println calls.

Also, I recommend looking into log4j. http://logging.apache.org/log4j.
You can configure it to log as much or as little as you want.

System.out.println is fine for small trivial apps and prototypes. Anything more than that requires a real logger.
Nitin Jawarkar
Ranch Hand

Joined: Dec 18, 2004
Posts: 79
Thanx,

I have change my log4j file according now it run better.

Thanx
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'm glad it's working for you.

It would have been helpful if you had mentioned that you were using log4j in your initial question. ;-)
suman deb
Ranch Hand

Joined: Jul 14, 2005
Posts: 54
Hi,

I have a question related to this topic. I am using tomcat 5.0.27 and my catalina.out is not cleaned/rollup and the size became around 1gb. Is there any way so that catalina.out will be cleaned automatically? Is there any property in logger.properties or server.xml which I can use?

Thanks
Suman
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61318
    
  66

Please do not post the same question more than once.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: How to clear log files?