Catalina Logs are not Rotated or Removed
症状
catalina.out
is not rotated- old
catalina.*.log
files are not removed
These log files can grow large in size.
原因
Confluence uses Tomcat's default logging configuration. This configuration means:
catalina.out
gets all output from stdout and stderr via ConsoleHandler, and also logs from bootstrap step when you start or stop Confluencecatalina.out
is never rotatedcatalina.YYYY-MM-DD.log
contains the output from stdout and stderr via FileHandler, but not the bootstrap logscatalina.YYYY-MM-DD.log
files are created on the first log event of that date, or when the Tomcat server starts. This means that if there is no log for that date, and the server was not started on that date, then the file is never created.catalina.YYYY-MM-DD.log
andcatalina.out
files are not removedlocalhost
,manager
andhost-manager
logs are configured similarly tocatalina.YYYY-MM-DD.log
files
ソリューション
Reduce the amount logged to
catalina.out
, by disabling the ConsoleHandler. This is done by modifying the conf/logging.properties file. Find the line that looks like this:conf/logging.properties.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
Change it to look like this:
conf/logging.properties.handlers = 1catalina.org.apache.juli.AsyncFileHandler
This will reduce the amount of logging to
catalina.out
, and does not lose any logging, since all of this output is already being put into the *.log files.Set up a scheduled job, using cron or some alternative, which removes old log files. For example to remove all the files older than one week, a script like this should do the job:
sample_catalina_log_clean.sh#!/bin/sh find $CONFLUENCE_INSTALL/logs -name 'catalina.*.log' -mtime +1w -print0 | xargs -0 rm -f
Remember to replace $CONFLUENCE_INSTALL with your actual Confluence install path, and to test your script on sample data to make sure you don't accidentally delete any logs that you want to keep.
The script above is just a suggestion. It's possible to use some other removal or archiving method if desired.