Tomcat 6 HTTP log rolling and purging

Solution 1:

I would suggest cleaning up the log files using a cron job (UNIX) or scheduled task (Windows).

First determine how long you want to keep the logs for, 1 week, 1 month, 3 months? Then run a script every day or so that removes the old logs. On Unix to delete log files older than 90 days:

find /path/to/httplogs/ -name "*.log" -type f -mtime +90 -exec rm -f {} \;

On windows a similar command can be used (forfiles is only available on some editions)

forfiles /p "C:\path\to\httplogs\" /s /m *.log /d -90 /c "cmd /c del @PATH"

Read the online documentation for these commands and understand and test what they are doing before putting them in a production environment.

If there is a common prefix for these logs then you can add this to the search mask to be more specific in which files are removed. Alternatively I often gzip older files rather than deleting them in case they prove useful later on.

Solution 2:

When you take a look at the source code of the class, for example here at google's code search you can see, that there is no purging at all. If you have someone around who could code some lines Java, one could easily extend the class and add the needed function.