Using Cronolog to split TOMCAT7 catalina.out logs

Source: Internet
Author: User

Tomcat log catalina.out will not be split by default, as the running time grows longer, the file becomes larger and bigger for the query is a big trouble, so use the Cronolog tool to split it.

1. Download Cronolog
Cronolog-1.6.2.tar.gz

2. Install Cronolog
# TAR-ZXVF Cronolog-1.6.2.tar.gz
# CD cronolog-1.6.2
#./configure
# Make && make install

3. Modify Tomcat's catalina.sh file
Modified as follows:
1) Will:
If [-Z "$CATALINA _out"]; Then
catalina_out= "$CATALINA _base"/logs/catalina.out
Fi
To
If [-Z "$CATALINA _out"]; Then
catalina_out= "$CATALINA _base"/logs/catalina.%y-%m-%d.out
Fi

2 Comment Touch "$CATALINA _out", about 370 lines
# touch "$CATALINA _out"

3) Will:
 if ["$" = "-security"]; then
 if [$have _tty-eq 1]; then
 echo "Using security M Anager "
 fi
 shift
 eval" \ $_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" $@ "Start \
 >>" $CATALINA _ Out "2>&1" & "

Else
Eval "\" $_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 "$@" Start \
>> "$CATALINA _out" 2>&1 "&"

Fi

Change to:
 if ["$" = "-security"]; then
 if [$have _tty-eq 1]; then
 echo "Using security Ma Nager "
 fi
 shift
 eval" \ $_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 "$@" Start \
 2>&1 |/usr/ Local/sbin/cronolog "$CATALINA _out".

Else
Eval "\" $_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 "$@" Start \
2>&1 |/usr/local/sbin/cronolog "$CATALINA _out" &

Fi

Modify complete, save exit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.