Tomcat8 uses cronolog to split Catalina.Out logs

Tomcat8 uses cronolog to split Catalina.Out logs

background

If the catalina.out log file generated by tomcat is not split, the file will often become larger and larger, affecting efficiency. At the same time, if you need to find a log file, it is quite troublesome to search in such a large catalina.out log file. It is best to split the catalina.out log file by day. Here is a split method: Use cronolog to split catalina.out log files

method

Install cronolog-1.6.2.tar.gz

Download address: cronolog-1.6.2.tar.gz

tar -zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configre # --prefix=/opt/cronolog, you can specify the installation directory, the default is /usr/local/sbin/cronolog
make
make install

tomcat configuration

Versions prior to Tomcat 7:

vim tomcat/bin/catalina.sh
# Comment out (#)
touch "$CATALINA_BASE"/logs/catalina.out
# Modify the two org.apache.catalina.startup.Bootstrap “$@” in the catalina.sh file in the tomcat bin directory start \
>> "$CATALINA_BASE"/logs/catalina.out 2>&1 &
# start 2>&1 for org.apache.catalina.startup.Bootstrap "$@" \
| /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &

After the completion, restart Tomcat and you can see the logs in the catalina.out.2015-09-13 format in the logs file.

Tomcat7 and later versions:

vi tomcat/bin/catalina.sh
#The first step is if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
Modify to if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out
fi
# The second step will touch "$CATALINA_OUT"
Change to #touch "$CATALINA_OUT"
echi "$CATALINA_OUT"
# The third step is to start org.apache.catalina.startup.Bootstrap "$@" \
>> "$CATALINA_OUT" 2>&1 &
Modify to org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
| /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &

After completion, restart Tomcat and you can see the catalina.out.2021-09-01 style log in the logs file.

This is the end of this article about Tomcat8 using cronolog to split Catalina.Out logs. For more information about Tomcat cronolog Catalina.Out log splitting, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

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

<<:  Vue+SSM realizes the preview effect of picture upload

>>:  A look into tool-based websites: the definition of tool-based websites and typical case analysis (pictures and text)

Recommend

Detailed explanation of the principles and usage of MySQL stored procedures

This article uses examples to explain the princip...

How to achieve centered layout in CSS layout

1. Set the parent container to a table and the ch...

Linux system disk formatting and manually adding swap partition

Windows: Support NTFS, FAT Linux supports file fo...

Why Google and Facebook don't use Docker

The reason for writing this article is that I wan...

An example of how to quickly deploy web applications using Tomcat in Docker

After learning the basic operations of Docker, we...

MySQL login and exit command format

The command format for mysql login is: mysql -h [...

Detailed explanation of MySQL user rights verification and management methods

This article uses examples to illustrate how to v...

Vue Basic Tutorial: Conditional Rendering and List Rendering

Table of contents Preface 1.1 Function 1.2 How to...

Summary of MySQL string interception related functions

This article introduces MySQL string interception...

MySQL 5.7 installation and configuration tutorial under CentOS7 (YUM)

Installation environment: CentOS7 64-bit, MySQL5....

How to compile and install opencv under ubuntu

Easy installation of opencv2: conda install --cha...

What is jQuery used for? jQuery is actually a js framework

Introduction to jQuery The jQuery library can be ...

WeChat applet implements the snake game

This article shares the specific code of the WeCh...