2

I'm using tomcat 7 on a virtual machine running Ubuntu. Right now, I have a catalina.out file at /var/lib/tomcat7/logs/catalina.out that is over 20GB in size. I tried first rotating the log file through this tutorial. I then found out that it will monitor it at the end of the night. Even starting the service manually didn't really do much. So I removed the file, but it appeared after I restarted tomcat.

I then tried doing what the accepted answer here was which was to go into conf/logging.properties and change the following line from:

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

to

.handlers = 1catalina.org.apache.juli.FileHandler

This seems to have worked for a minute, at least until I re-started my virtual machine. Once that happened, I ended up with another 20GB catalina.out file.

Is there some proven way that will either stop the file from getting above 5MB or will just limit the file at all?

Community
  • 1
  • 1
Alex
  • 2,145
  • 6
  • 36
  • 72
  • You should have a deep look into [logging in java](https://docs.oracle.com/javase/8/docs/technotes/guides/logging/overview.html) and [logging with Tomcat](http://tomcat.apache.org/tomcat-7.0-doc/logging.html). – Stefan Apr 20 '16 at 07:48
  • http://stackoverflow.com/questions/8342336/how-to-set-maximum-number-of-rolls-and-maximum-log-size-for-tomcat – Stefan Apr 20 '16 at 07:52

1 Answers1

-1

Mulesoft exlains this in Rotating Catalina.out:

There are two answers.

The first, which is more direct, is that you can rotate Catalina.out by adding a simple pipe to the log rotation tool of your choice in Catalina's startup shell script. This will look something like:

"$CATALINA_BASE"/logs/catalina.out WeaponOfChoice 2>&1 &

Simply replace "WeaponOfChoice" with your favorite log rotation tool.

The second answer is less direct, but ultimately better. The best way to handle the rotation of Catalina.out is to make sure it never needs to rotate. Simply set the "swallowOutput" property to true for all Contexts in "server.xml".

This will route System.err and System.out to whatever Logging implementation you have configured, or JULI, if you haven't configured it. All commons-logger implementations rotate logs by default, so rotating Catalina.out is no longer your problem.

jmehrens
  • 10,580
  • 1
  • 38
  • 47