Tomcat Log Auto-segmentation (Linux) Cronolog

Source: Internet
Author: User

The log output of Tomcat on Linux is in Catalina.out, and as time goes by, the resulting log files will become bigger and larger, mainly in the debugging of some of the information printed in space, such as System.out and log and so on. Tomcat's Catalina.out file is constantly expanding, causing the system disk space edge to become smaller, also inconvenient to view, so use Cronolog by date to split the log (in the example of the split units in days).

    • Cronolog Installation

    1. # tar zxvf cronolog-1.6.2.tar.gz# cd cronolog-1.6.2#./configure# make# Make Install
  • Check the directory where the Cronolog is installed (verify that the installation was successful)

    # which Cronolog

    Normal display:

    /usr/local/sbin/cronolog

  • To split Tomcat's catalina.out, you need to do the following:

    Previous versions of TOMCAT7:

    (1) Comment out (#)

    Touch "$CATALINA _base"/logs/catalina.out

    (2) Modify two of the catalina.sh files in the Tomcat bin directory

    Org.apache.catalina.startup.Bootstrap "[email protected]" start \

    >> "$CATALINA _base"/logs/catalina.out 2>&1 &

    For

    Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1 \

    | /usr/local/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null &

  • When you are finished, you can restart Tomcat to see the catalina.out.2015-09-13 style log in the logs file.

  • TOMCAT7 later versions:
    1 First Step

    Will

    If [-Z "$CATALINA _out"]; Then

    catalina_out= "$CATALINA _base"/logs/catalina.out

    Fi

    Revision changed to

    If [-Z "$CATALINA _out"]; Then


    catalina_out= "$CATALINA _base"/logs/catalina.%y-%m-%d.out

    Fi

  • 2 Step Two

    Will

    Touch "$CATALINA _out"

    Switch

    #touch "$CATALINA _out"

  • 3 Step Three

    Will

    Org.apache.catalina.startup.Bootstrap "[email protected]" start \

    >> "$CATALINA _out" 2>&1 &

    Revision changed to

    Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1 \

    | /usr/local/sbin/cronolog "$CATALINA _out" >>/dev/null &

  • or perform the following procedure as follows (recommended):

# 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

........

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 "[email protected]" Start 2>&1 \

| /usr/local/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null &

Fi

650) this.width=650; "src=" Http://www.linuxidc.com/upload/2016_07/160726075138241.png "width=" 705 "vspace=" 5 "style = "border:0px;"/>

When you are finished, you can restart Tomcat to see the catalina.out.2015-09-13 style log in the logs file.



This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1960817

Tomcat Log Auto-segmentation (Linux) Cronolog

Related Article

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.