Several ways to automatically archive Tomcat catalina.out under Linux

Source: Internet
Author: User

question: Why do I need to archive?
    • if the Catalina.out log reaches 2GB size, Tomcat has no way to continue outputting the log because of cache problems.
    • in order to avoid this situation, you need to archive the catalina.out in a timely manner.

problem: Tomcat itself archives the contents of the log, why the log is still getting bigger
    • in fact, Tomcat itself also archives the contents of the log, but after archiving, Tomcat will not clean up the contents of the catalina.out, which will cause catalina.out to become more and more large

Solution Solutions
    usage Scenario: Linux/unix
    Execute command:
    Vi/etc/logrotate.d/tomcat



    Enter the following:
    /opt/apache-tomcat-8.0.15/logs/catalina.out{  rotate copytruncate  daily  dateext nocompress  Missingok  Notifempty  }




    parameter function:
    • copytruncate for log files that are still open, to back up and truncate the current log
    • daily Specify a dump cycle of daily-
    • Dateext Use date as a named format, the toggled log file appends the date of the previous dash and YYYYMMDD format
    • Example: error.log-20150506, no this configuration item appends a decimal point plus a numeric ordinal
    • nocompress When compression is not required, use this parameter
    • Missingok Ignore this warning message if the log does not exist
    • Notifempty indicates that if the log file is empty, it will not be rotate

once you 're done, you don't need to do any work on your operating system, and the log archiver will archive your logs every day.

Execute Command


/usr/sbin/logrotate-f/etc/logrotate.conf



===================== not to be continued, leave a pit let oneself study well ===========================

Several ways to automatically archive Tomcat catalina.out under Linux

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.