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

How to install and deploy MySQL 8.0 under CentOS8

MySQL 8 official version 8.0.11 has been released...

Detailed explanation of the setting of background-image attribute in HTML

When it comes to pictures, the first thing we thi...

Web development tutorial cross-domain solution detailed explanation

Preface This article mainly introduces the cross-...

XHTML Getting Started Tutorial: What is XHTML?

What is HTML? To put it simply: HTML is used to m...

Analysis of the HTML writing style and reasons of experienced people

1. Navigation: Unordered List vs. Other Label Ele...

Vue implements horizontal scrolling of marquee style text

This article shares the specific code for Vue to ...

12 Useful Array Tricks in JavaScript

Table of contents Array deduplication 1. from() s...

Tutorial on using iostat command in Linux

Preface It is said that if the people doing opera...

Super detailed tutorial to implement Vue bottom navigation bar TabBar

Table of contents Project Introduction: Project D...

Specific use of node.js global variables

Global Object All modules can be called global: r...

Baidu Input Method opens API, claims it can be ported and used at will

The relevant person in charge of Baidu Input Metho...

Combining XML and CSS styles

student.xml <?xml version="1.0" enco...

Vue multi-page configuration details

Table of contents 1. The difference between multi...

Detailed explanation of Vue slot

1. Function : Allows the parent component to inse...

React Fragment Introduction and Detailed Usage

Table of contents Preface Motivation for Fragment...