Solve the problem of catalina.log log files under the Tomcat log directory under Linux

Source: Internet
Author: User

 This digest from: (http://blog.csdn.net/stevencn76/article/details/6246162)Category: Java technology zone 2011-03-13 12:25 5017 People read Comments (1) favorite reports Tomcatlinux Tool Task Web

Since Tomcat produces log output from a web app that is not configured by default to its own log content, the size of the file will become larger over time, and the time required to check the log content will cause the file to be hard to open. And while Tomcat continues to enter content into files, it also reduces Tomcat performance. The following is a tool to split the Catalina.out file generated by Tomcat into a separate file based on the date, so that a single log file is not too large, and an outdated log file can be deleted or backed up elsewhere, depending on the situation.

Here is a tool called Cronolog, which is used to redirect content from the standard output to a file, but can be named according to the rules, so that we can redirect the contents of the standard output to a log file named according to the date, Then just point the Tomcat's log output to the standard output to fix the problem. Here are the specific configuration steps

I. Acquisition and installation of Cronolog tools

1. To download the latest version here (http://cronolog.org/download/index.html), the latest version of this article was written in version 1.6.2.

2. Unzip the downloaded file, tar xvzf cronolog.tar.gz

3. Switch to the Cronolog directory after decompression

4. Initializing and compiling the installation

./configure--prefix=/usr/local/cronolog (where the path behind--prefix is where you want the tool to be installed)

./make

./make Install

Ii. Modifying the Tomcat boot file (tomcat/bin/catalina.sh)

1. Locate the following in the file (note: There are two places)

Org.apache.catalina.startup.Bootstrap "[email protected]" Start/
>> "$CATALINA _base"/logs/catalina.out 2&1 &


Modify it to the following format:

Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1/
| /usr/local/cronolog/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null &

2. Note the following

#touch "Catalina_base"/logs/catalina.out

And then restart Tomcat to complete the mission.

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.