Tomcat Log Cutting

Source: Internet
Author: User

logrotate is a powerful system software, it has a complete set of operating mode for log files, such as: Dump, mail and compression, and the default logrotate


added to Cron ( /etc/cron.daily/logrotate ) as daily task execution. Automatically with logrotate, I don't want to write my own log cutting scripts.

the following Tomcat Log Catalina.out Log Cutting

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7C/CB/wKiom1bX9tugiULbAAFFNx9JtXk148.png "title=" 4.png " Style= "Float:none;" alt= "Wkiom1bx9tugiulbaaffnx9jtxk148.png"/>

the following Tomcat Log Catalina.out Log Cutting

Ls-lh/usr/local/tomcat/logs/catalina.out

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7C/CB/wKiom1bX9trDbUOKAAAkqjDeBPM203.png "style=" float: none; "title=" 1.png "alt=" Wkiom1bx9trdbuokaaakqjdebpm203.png "/>


# Cat/etc/logrotate.d/tomcat

/usr/local/tomcat/logs/catalina.out {

Daily

Rotate 5

Missingok

Dateext

Compress

Notifempty

Copytruncate

}

Detailed parameters:

Daily Specify a dump cycle of daily

Rotate 5 specifies the number of times the log file was dumped before it was deleted . 0 means no backup, 5 means reserved 5 a backup

Missingok Ignore this warning message if the log does not exist

Dateext file suffix is date format , that is, after the cut file is : xxx.log-20150828.gz

Compress through gzip compress dumps after the log ( gzip-d xxx.gz decompression)

Notifempty If it is an empty file, do not dump

copytruncate for log files that are still open, put the current log Backup and truncation

Truncate log immediately:

# logrotate--force/etc/logrotate.d/tomcat

# Ls-lh/usr/local/tomcat/logs/catalina.out

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7C/CB/wKiom1bX9x3zQ_X6AAA0G4z0WOM591.png "style=" float: none; "title=" 2.png "alt=" Wkiom1bx9x3zq_x6aaa0g4z0wom591.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7C/CA/wKioL1bX95fCA60ZAAAhaFX2ovI450.png "style=" float: none; "title=" 3.png "alt=" Wkiol1bx95fca60zaaahafx2ovi450.png "/>


Oh, later to view the Tomcat log is particularly convenient


This article is from the "Brother to share" blog, please be sure to keep this source http://renzhiyuan.blog.51cto.com/10433137/1747213

Tomcat Log Cutting

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.