Use Cronolog to cut Tomcat logs in Ubuntu environment

Source: Internet
Author: User

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

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.