A brief analysis of the relationship between various Tomcat logs and the segmentation of catalina.out files

A brief analysis of the relationship between various Tomcat logs and the segmentation of catalina.out files

The relationship between Tomcat logs

A picture is worth a thousand words!

In other logs such as localhost.{yyyy-MM-dd}.log and localhost-access.{yyyy-MM-dd}.log , localhost is the name of the context, and often an application is the name.

Split catalina.out

As shown in the figure above, catalina.out will only get bigger as the running time gets longer, but the logs output by the console are also useful. For example, some developers like to use e.printStackTrace() , System.out.println() , and System.err.println() will all be printed to catalina.out. These logs are also useful! Therefore, log segmentation is needed for backup.

The easiest way is to use the logrotate function that comes with Linux to split catalina.out.

Take the catalina.out path as /opt/tomcat/logs/catalina.out as an example:

#Enter /etc/logrotate.d. This directory is the configuration directory of the logrotate.d subsystem. It is not recommended to modify the main configuration file.
cd /etc/logrotate.d
cat > tomcat<<EOF
/opt/tomcat/logs/catalina.out{
        copytruncate
	daily
        rotate 15
        compress
        missingok
        notifempty
        size 200M
        dateext
}
EOF

The above configuration description:

  • /opt/tomcat/logs/catalina.out #catalina.out storage address
  • copytruncate #Copy the original log file and clear it
  • daily #Daily cutting
  • rotate 15 #Keep up to 15 files
  • compress #Compress the split files
  • missingok #Allow catalina.out file not to exist, and start cutting after the file appears
  • notifempty #When the log file is empty, no rotation is performed
  • size 200M #When catalina.out file is larger than 200M, cut
  • dateext # Date extension, add the date to the log file name after cutting

More configuration parameters:

compress #Compress the dumped logs with gzip nocompress #Do not perform gzip compression copytruncate #Used for log files that are still open, back up and truncate the current log; it is a copy-first-then-clear method. There is a time difference between copying and clearing, and some log data may be lost.
nocopytruncate #Backup the log file but do not truncate it create mode owner group #Specify the properties of creating new files during rotation, such as create 0777 nobody nobody
nocreate #Do not create a new log file delaycompress #When used with compress, the dumped log file will not be compressed until the next dump nodelaycompress #Override the delaycompress option and compress while dumping.
missingok #If the log is missing, no error is reported and the next log is rolled. errors address #Error messages during storage are sent to the specified Email address ifempty #Even if the log file is empty, the file is rotated. This is the default option of logrotate.
notifempty #When the log file is empty, do not rotate mail address #Send the dumped log file to the specified E-mail address nomail #Do not send the log file when dumping olddir directory #Put the dumped log file in the specified directory, which must be in the same file system as the current log file noolddir #Put the dumped log file and the current log file in the same directory sharedscripts #Run the postrotate script, which is used to execute the script once after all logs are rotated. If this is not configured, the script will be executed once after each log rotation. prerotate #Instructions to be executed before logrotate dumps, such as modifying file attributes and other actions; must be independent lines. postrotate #Instructions to be executed after logrotate dumps, such as restarting (kill -HUP) a service! Must be a separate line daily #Specify the dump cycle as dailyweekly #Specify the dump cycle as weeklymonthly #Specify the dump cycle as monthlyrotate count #Specify the number of dumps before the log file is deleted. 0 means no backup, 5 means retaining 5 backupsdateext #Use the current date as the naming formatdateformat .%s #Use with dateext, appear immediately on the next line, define the file name after the file is cut, must be used with dateext, only supports %Y %m %d %s these four parameterssize value and unit #The log file is dumped when it reaches the specified size. The missing unit is bytes, which can be specified in KB or MB

For more parameters, please refer to the article: https://cloud.tencent.com/developer/article/1681716

This is the end of this article about the relationship between various Tomcat logs and the segmentation of catalina.out files. For more information about the segmentation of Tomcat catalina.out files, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Catalina.out log file segmentation under Linux tomcat
  • Tomcat uses Log4j to output catalina.out log
  • Detailed explanation of three ways to cut catalina.out logs in tomcat

<<:  Life cycle and hook functions in Vue

>>:  CSS float (float, clear) popular explanation and experience sharing

Recommend

MySql COALESCE function usage code example

COALESCE is a function that refers to each parame...

CentOS6.9+Mysql5.7.18 source code installation detailed tutorial

CentOS6.9+Mysql5.7.18 source code installation, t...

Docker volumes file mapping method

background When working on the blockchain log mod...

Detailed installation tutorial for MySQL zip archive version (5.7.19)

1. Download the zip archive version from the offi...

Seven different color schemes for website design experience

The color matching in website construction is ver...

MySQL 8.0.19 installation and configuration tutorial under Windows 10

I will be learning MySQL next semester. I didn...

jQuery implements simple button color change

In HTML and CSS, we want to set the color of a bu...

The difference between VOLUME and docker -v in Dockerfile

There are obvious differences between volume moun...

Example of using CSS3 to create Pikachu animated wallpaper

text OK, next it’s time to show the renderings. O...

Detailed explanation of Vue two-way binding

Table of contents 1. Two-way binding 2. Will the ...

Using zabbix to monitor the ogg process (Linux platform)

The ogg process of a database produced some time ...

How to change the MySQL database directory location under Linux (CentOS) system

How to change the MySQL database directory locati...