This digest from: (http://blog.csdn.net/stevencn76/article/details/6246162)Category: Java technology zone 2011-03-13 12:25 5017 People read Comments (1) favorite reports Tomcatlinux Tool Task Web
Since Tomcat produces log output from a web app that is not configured by default to its own log content, the size of the file will become larger over time, and the time required to check the log content will cause the file to be hard to open. And while Tomcat continues to enter content into files, it also reduces Tomcat performance. The following is a tool to split the Catalina.out file generated by Tomcat into a separate file based on the date, so that a single log file is not too large, and an outdated log file can be deleted or backed up elsewhere, depending on the situation.
Here is a tool called Cronolog, which is used to redirect content from the standard output to a file, but can be named according to the rules, so that we can redirect the contents of the standard output to a log file named according to the date, Then just point the Tomcat's log output to the standard output to fix the problem. Here are the specific configuration steps
I. Acquisition and installation of Cronolog tools
1. To download the latest version here (http://cronolog.org/download/index.html), the latest version of this article was written in version 1.6.2.
2. Unzip the downloaded file, tar xvzf cronolog.tar.gz
3. Switch to the Cronolog directory after decompression
4. Initializing and compiling the installation
./configure--prefix=/usr/local/cronolog (where the path behind--prefix is where you want the tool to be installed)
./make
./make Install
Ii. Modifying the Tomcat boot file (tomcat/bin/catalina.sh)
1. Locate the following in the file (note: There are two places)
Org.apache.catalina.startup.Bootstrap "[email protected]" Start/
>> "$CATALINA _base"/logs/catalina.out 2&1 &
Modify it to the following format:
Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1/
| /usr/local/cronolog/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null &
2. Note the following
#touch "Catalina_base"/logs/catalina.out
And then restart Tomcat to complete the mission.