Tomcat's log file is called catalina.out. Without setting up rolling logs, this log can get quite large. This works by installing JULI, which is a log manager specific to Tomcat. JULI is enabled by default in Tomcat, but we must install some extra files to get it to work with log4j. The following is an example of how log messages work. In this example, let's assume that today is August 13, 2009. You start catalina by running bin/catalina.sh start and log messages are written out to catalina.out. At midnight, all the log messages in catalina.out are moved to catalina.out.2009-08-13 and catalina.out is emptied. The log messages for your current day (August 14, 2009) are written to catalina.out. When midnight comes again, the messages from August 14, 2009 are moved into catalina.out.2009-08-14 and new messages go intocatalina.out. The titles of the logs from previous days will always be in the catalina.out.YYYY-MM-dd format. ie for December 31st, 2008 this would be catalina.out.2008-12-31. These instructions explain how to set up rolling logs:
3. Go to the Tomcat archives. On the webpage, click on the link for your tomcat version. Then navigate to the bin\extras page and download tomcat-juli.jar and tomcat-juli-adapters.jar.
This creates a logger with logging level "info" that rolls catalina.out every day at midnight. The stdout logger ensures that standard out is also sent to the console, so that you can easily see if there are any errors with running tomcat.
We included these alternate instructions because the issue with duplicate entries happen on some platforms and not others. These instructions are a modified version of the Tomcat logging instructions. If you would like to delete old logs, you might want to run a cronjob to search for old logs and delete them. You can run crontab -e to create a cronjob. There you should enter something like: 0 0 * * * find $CATALINA_HOME/logs -type f -mtime +30 | xargs --no-run-if-empty rm This will run the job every day at midnight. The job uses find to purge log files 30 days old or older. (责任编辑:IT) |