Foreword: Tomcat log is cut by date
Using cronolog to segment the image of tomcat9 catalina.out Log; Tomcat’s catalina.out The log file cannot be divided by date. All the log files are output and written to a single file catalina.out In this way, the. Out log will become larger and larger, and the cost of operation and maintenance will increase. To archive log files by date, cronolog can be used to realize log segmentation.
1. Step 1: cronlog installation
Use the yum command to install cronlog
yum install cronolog
2. Step 2: modify catalina.sh Documents
Directory: Tomcat/bin/ catalina.sh
Original setting:
After modification:
shift
# touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then
if [ $have_tty -eq 1 ]; then
echo "Using Security Manager"
fi
shift
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
-classpath "\"$CLASSPATH\"" \
-Djava.security.manager \
-Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
-Dcatalina.base="\"$CATALINA_BASE\"" \
-Dcatalina.home="\"$CATALINA_HOME\"" \
-Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
org.apache.catalina.startup.Bootstrap "$@" start \
2&>&1 | /usr/local/sbin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &
else
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
-classpath "\"$CLASSPATH\"" \
-Dcatalina.base="\"$CATALINA_BASE\"" \
-Dcatalina.home="\"$CATALINA_HOME\"" \
-Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
org.apache.catalina.startup.Bootstrap "$@" start \
2&>&1 | /usr/local/sbin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &
fi
3. Step 3: restart Tomcat
Restart Tomcat and the log will take effect according to the date. A screenshot of the log file is shown below.
Read More:
- [Solved] GP tool Call Error: ERROR 000824: The tool is not licensed.
- log4j Error: Please initialize the log4j system properly [How to Solve]
- [Solved] kafka Startup Error: ERROR Shutdown broker because all log dirs in /…/kafka/logs have failed (kafka.log.LogManager)
- [Solved] ERROR: Unable to find the development tool `cc`
- Log jar package conflict error: Class path contains multiple SLF4J bindings
- [Solved] logback log format adjustment error: Failed to create converter for [%M] keyword
- Eclipse start project error: Errors occurred during the build. Errors running builder ‘Integrated External Tool Builder’ on…
- rsyslog Write into Log File Error [How to Solve]
- MAC-XXL_JOB Error: Failed to create parent directories for [/data/applogs/xxl-job/xxl-job-admin.log
- Log4j2 reports ERROR StatusLogger Unrecognized format specifier
- Buffer I/O Error in /var/log/messages
- log4j:WARN No appenders could be found for logger (freemarker.cache)
- [Gradle is Stucked in Building Runing] log Error: Timeout waiting to lock journal cache
- [Solved] SpringMVC Error: war exploded: Error during artifact deployment. See server log for details.
- [Solved] Junit.test use error: log4j:WARN No appenders could be found for logger
- [Solved] SSM Project Error: Error during artifact deployment. See server log for details.
- How to Solve Excel Error Log 2: Sloving method
- [Solved] Excel solver: Error Log 3_Decimal result after non negative constraint
- Cmake Compile opencv error: The system is: Windows – 10.0.19042 – AMD64 (Log File)
- [Solved] Event Log Error: Failed to retrieve application JMX service URL