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