because the Tomcat default The log file does not start splitting, Catalina.out the continuous expansion of the file, resulting in a smaller system disk space, and management is difficult to manage, so you want to use a tool to split it. For ease of management, the split log keeps daily logs in a single file for easy log management. This article uses the cronolog tool.
The installation process is as follows:
1. Download (latest version)
# wgethttp://cronolog.org/download/cronolog-1.6.2.tar.gz
2 , decompression
# tar Zxvfcronolog-1.6.2.tar.gz
3 , enter Cronolog directory where the installation files are located
# CD cronolog-1.6.2
4 , run the installation
#./configure
# make
# make Install
5 , view Cronolog Directory after installation (verify the installation is successful)
# which Cronolog
typically shown as: /usr/local/sbin/cronolog
tomcat catalina.out
Modify Tomcat bin under the directory catalina.sh in the file
Org.apache.catalina.startup.Bootstrap "[email protected]" Start \>> "$CATALINA _base"/logs/catalina.out 2> &1 &
to be
Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1 \ | /usr/local/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null &
Also, there is a row in the file
Touch "$CATALINA _base"/logs/catalina.out
Comment out, then reboot tomcat into the log directory to see if the cut was successful.
As below, change to red section.
Shift
Touch "$CATALINA _out"
If ["$" = "-security"]; Then
If [$have _tty-eq 1]; Then
echo "Using Security Manager"
Fi
Shift
eval \ "$_runjava\" \ "$LOGGING _config\" $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 \
2>&1 |/usr/local/sbin/cronolog "$CATALINA _base/logs/catalina.%y-%m-%d.out" &
# >> "$CATALINA _out" 2>&1 "&"
Else
eval \ "$_runjava\" \ "$LOGGING _config\" $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 "$CATALINA _base/logs/catalina.%y-%m-%d.out" &
# >> "$CATALINA _out" 2>&1 "&"
Fi
This article is from the "Linux Technology" blog, so be sure to keep this source http://lihuan.blog.51cto.com/4391550/1557765
Tomcat Log segmentation under Linux