Tomcat log file catalina.out log cutting tool installation

Source: Internet
Author: User

Summary:

A friend with Tomcat should know that it writes log files to the Catalina.out file, which is growing, and the log file is not very friendly. So we need to cut this file and show it as a file according to our needs, and we can clean up what we don't need on a regular basis.

Simple installation steps:

1, we use a log cutting tool cronolog.1.6.2.tar.gz

We'll install the GCC compiler before downloading this file.

#yum-y Install gcc

Download the cutting tool, the following two connections can be downloaded to, any selection of the line.

#wget http://download.chinaunix.net/down.php?id=3457&ResourceID=1851&site=1

Or

#wget http://pkgs.fedoraproject.org/repo/pkgs/cronolog/cronolog-1.6.2.tar.gz/a44564fd5a5b061a5691b9a837d04979/ Cronolog-1.6.2.tar.gz

Unzip the compilation after downloading:

#tar-XZVF cronolog.1.6.2.tar.gz

#cd cronolog.1.6.2

#./configure--prefix=/usr/local/cronolog

#make

#make Install

2. Modify the configuration file

#cd to Tomcat/bin/catalina.sh

#vi catalina.sh

2 Places found:

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

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

To be replaced by:

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 &

and comment out touch "$CATALINA _out"

# touch "$CATALINA _out"

Save exit.

3. Create a script to delete logs (delete logs for more than 60 days)

#vi/usr/local/tomcat/bin/rmcatalina.sh

Insert the code:

#===================================================

#!/bin/sh

find/usr/local/tomcat/logs/-type f-mtime +60-exec rm-rf {} \;

#==================================================

Then change the file to execute permissions:

#chmod 755/usr/local/tomcat/bin/rmcatalina.sh

Add a task Schedule

(You can view the current configuration with Crontab-l first,

Then use the CRONTAB-E editor,

Vi/etc/crontab if not enabled)

Add: (Example: 1th number 00:00 per month to be executed once)

0 0 1 * *./usr/local/tomcat/bin/rmcatalina.sh

Finish editing to make it effective.

Load configuration system Scheduled task file

Ensure Crond service status before operational task scheduling

To view service commands:

Service Crond Status

To open a command:

Service Crond Start

Reload Config file command (/etc/crontab: for file path):

Crontab/etc/crontab

View configuration commands (view configuration information):

Crontab-l

To edit a task Schedule command:

Crontab-e

To view a process:

Ps-ef |grep Crond

Of course, after the above steps are over, remember to restart Tomcat to see if it takes effect.

This is still relatively simple not difficult, make a note to prevent too long no operation forgot.

This article is from the "very strong ant" blog, make sure to keep this source http://leozhang2016.blog.51cto.com/9419901/1762883

Tomcat log file catalina.out log cutting tool installation

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.