Set up log rotation to avoid a large increase in Tomcat catalina.out files

Source: Internet
Author: User

Create a logrotate configuration file

$ vi/etc/logrotate.d/tomcat

Add the following content:

/opt/entermediadb/tomcat/logs/catalina.out {    copytruncate    daily    rotate 7  compress    Missingok    dateext  Size 100m  

Parameter description:

Specify the path to the log file. Copytruncate–creates a copy of the log file and then truncates the original to an empty file so that the service can Kee P on logging uninterrupted.daily–rotates the Catalina.out daily.rotate–keeps for most 7 log files. Compress–create a gzip compressed file of the rotated files.missingok–suppresses error messages if the file does not E Xist. Dateext–add the date to the filename of the archived log file.size–rotates if the size of catalina.out is bigger than 100m.  

  

Files can be found on most Linux systems:/etc/cron.daily/logrotate, the file is run every day. The runtime calls:

This will rotate out the tomcat log.
If you have more than one Tomcat instance, you need to configure multiple separate rotation files.

You can also write scheduled tasks manually:

2 * * * */USR/SBIN/LOGROTATE/ETC/MYLOGROTATE.D/TOMCAT

  

Set up log rotation to avoid a large increase in Tomcat catalina.out files

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.