Use cronolog to separate Tomcat logs

Source: Internet
Author: User

Shen xiaoran Date:

Install cronolog

Download: http://cronolog.org/usage.html

./Configure
Make; make install

Default installation location:

# Which cronolog
/Usr/local/sbin/cronolog

Configure Tomcat log Segmentation

Edit the Catalina. Sh file in the bin directory of Tomcat

# Vi bin/Catalina. Sh

Find the following line

Org. Apache. Catalina. startup. Bootstrap "[email protected]" Start \
> "$ Catalina_out" 2> & 1 &

There are two rows like this. The first is Tomcat startup with the "-Security" parameter, and the second is the default Tomcat startup mode, that is, the part below Else, we only need to modify it here.

In addition, you need to comment out the "$ catalina_out" line of touch.

The complete modification is as follows:

# Touch "$ catalina_out"
If ["$1" = "-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 and exit

Restart 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.6.0 _ 29
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.6.0 _ 29
Using classpath:/usr/local/tomcat/bin/Bootstrap. Jar

Check whether the log file Catalina. yymmdd. Out is generated in the log directory.

-RW-r -- 1 Root 10537 Jul 30 10:50 catalina.20140730.out

After cronolog configuration is complete, check whether a new Catalina. yymmdd. Out log file is generated every day and regularly Delete older log files.

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.