Tomcat – How to disable logging in Tomcat 7

loggingtomcat

I have a Tomcat 7 server running in a VM that has very little disk space (20G).

Over the course of a few days Tomcat will fill the space with logging info (usually about 15G before it runs out).

I've tried turning down the log level (from INFO to SEVERE) in the logging.properties file, I've also tried sending the log info to /dev/null.

It doesn't seem to work as I still get a full log directory after no time at all.

Can I put a file size limit on the log files? Is something overriding the properties I'm setting?

Where can I find this information? My Google Fu just returns information about logging from within an application using JULI.

Best Answer

Play around with RollingFileAppenders (Log4J) to roll them when they get too large and use cron jobs to delete old logs. You can easily limit logfiles to 50M or so.

To shut down logging completely rename the logging.properties into something else. Tomcat will then default to use console logging which is almost like > /dev/null. Finally put a comment around all valves in your server.xml to mute those too. Now shut the tomcat down, delete all remaining logfiles and start it back up. There should be no logfiles created in /log.