1, installation Cronolog
wget http://down1.chinaunix.net/distfiles/cronolog-1.6.2.tar.gz
./configure
Make && sudo make install
Default installation Location:
# which Cronolog
/usr/local/sbin/cronolog
2. Configure the split Tomcat log
Edit the catalina.sh file under the Tomcat directory bin
# VI bin/catalina.sh
Find the following line
Org.apache.catalina.startup.Bootstrap "[email protected]" start \
>> "$CATALINA _out" 2>&1 &
There are 2 lines like this, the first is Tomcat with the "-security" parameter of the start, the second is the default Tomcat boot mode, which is the other part of the other, we only modify here.
In addition, the touch "$CATALINA _out" this line commented out.
The complete changes are as follows:
# touch "$CATALINA _out"
If ["$" = "-security"]; Then
If [$have _tty-eq 1]; Then
echo "Using Security Manager"
Fi
Shift
"$_runjava" "$LOGGING _config" $LOGGING _manager $JAVA _opts $CATALINA _opts \
-djava.endorsed.dirs= "$JAVA _endorsed_dirs"-classpath "$CLASSPATH" \
-djava.security.manager \
-djava.security.policy== "$CATALINA _base"/conf/catalina.policy \
-dcatalina.base= "$CATALINA _base" \
-dcatalina.home= "$CATALINA _home" \
-djava.io.tmpdir= "$CATALINA _tmpdir" \
Org.apache.catalina.startup.Bootstrap "[email protected]" start \
>> "$CATALINA _out" 2>&1 &
Else
"$_runjava" "$LOGGING _config" $LOGGING _manager $JAVA _opts $CATALINA _opts \
-djava.endorsed.dirs= "$JAVA _endorsed_dirs"-classpath "$CLASSPATH" \
-dcatalina.base= "$CATALINA _base" \
-dcatalina.home= "$CATALINA _home" \
-djava.io.tmpdir= "$CATALINA _tmpdir" \
Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1 | /usr/local/sbin/cronolog/usr/local/tomcat/logs/catalina.%y%m%d.out >>/dev/null &
# >> "$CATALINA _out" 2>&1 &
Fi
Save exit
Restart the Tomcat service
[Email protected] tomcat]# bin/shutdown.sh
Using catalina_base:/usr/local/tomcat
Using Catalina_home:/usr/local/tomcat
Using Catalina_tmpdir:/usr/local/tomcat/temp
Using Jre_home:/usr/java/jdk1.8.0_23
Using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar
[Email protected] tomcat]# bin/startup.sh
Using catalina_base:/usr/local/tomcat
Using Catalina_home:/usr/local/tomcat
Using Catalina_tmpdir:/usr/local/tomcat/temp
Using Jre_home:/usr/java/jdk1.8.0_23
Using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar
To see if the log directory generates catalina.yymmdd.out log files
-rw-r--r--1 root root 10537 Jul 10:50 catalina.20150527.out
Configuration Cronolog completed, observing whether there is a new catalina.yymmdd.out log file generated every day, periodically deleting older log files.
Use Cronolog to cut Tomcat logs in Ubuntu environment