Tomcat Log segmentation under Linux

Source: Internet
Author: User

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

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.