How to delete Tomcat Access Log after n days?

By default rotatable is true for Access Log, so you will be having a new file created every 24 hours.

Tomcat itself does not do any housekeeping on the old files, the general principle on a Unix system is to have a cron job set up on the system to archive older files into a back up directory and/or delete them.


For Tomcat 7 you can config tomcat/conf/logging.properties. Example:

1catalina.org.apache.juli.FileHandler.maxDays = 90

Note: that 1 is not a typo.

https://tomcat.apache.org/tomcat-7.0-doc/logging.html

Note: this does not affect access log files, which are handled by the Access Log Valve, not by the main Tomcat (Apache Commons) logging.

Tags:

Logging

Tomcat