Tomcat Log Management

One of the drawbacks of the default Tomcat setup is that the logfiles aren't written to the sensible location on Unix and Linux systems. This isn't hard to correct.

Here's how. (Examples of configuration settings in server.xml and so on go here).

While you're at it, you should consider tweaking what logs are written.

Different types of logs you can have.

Recommendations for paring it down for production.

Tweaks to make for debugging.

What you may want on development.

Tweaking the log4j configuration to control what you log.

Retention policy. Decide how long you want to keep your logs. Important logs, e.g. where you have applications write data that need to be collated and reported on for business reasons, should be archived.

(example of logrotate configuration file for tomcat logs)

The catalina.out log. This is a bit of a pain, because unlike the other logs you can't have it rotate automatically. The only way to rotate it is to rename the file and restart the server.

(Research this, is there a better way? Could get very fancy with a named pipe or something)

Include catalina.out rotation in the start/stop script.