Tomcat's default log uses java.util.logging, which has several shortcomings. The file catalian.out cannot be generated daily like log4j, and will become larger and larger. The log format is inconsistent with that printed by log4j in the project, which is not conducive to parsing. I searched on the official website of Tomcat (https://tomcat.apache.org/tomcat-7.0-doc/logging.html) and found that by modifying some configurations and replacing the extension package, you can use log4j to output catalian.out. Create a log4j.properties file in $CATALINA_BASE/lib The content of log4j.properties is as follows: log4j.rootLogger = INFO, CATALINA # Define all the appenders log4j.appender.CATALINA = org.apache.log4j.DailyRollingFileAppender log4j.appender.CATALINA.File = ${catalina.base}/logs/catalina.out log4j.appender.CATALINA.Append = true log4j.appender.CATALINA.Encoding = UTF-8 # Roll-over the log once per day log4j.appender.CATALINA.DatePattern = '.'yyyy-MM-dd log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout #log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n log4j.appender.CATALINA.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %p [%t] %c | %m%n # configure customed log to catalina.out log4j.logger.com.xxxxx = WARN, CATALINA log4j.logger.org.apache = WARN, CATALINA log4j.logger.org.mybatis = WARN, CATALINA log4j.logger.java.sql = WARN, CATALINA log4j.logger.org.springframework = WARN, CATALINA Update tomcat related jar packages Download log4j-1.2.17.jar (http://www.apache.org/dist/logging/log4j/1.2.17/) Download two jar packages of tomcat7: tomcat-juli.jar and tomcat-juli-adapters.jar (http://www.apache.org/dist/tomcat/tomcat-7/v7.0.69/bin/extras/, preferably corresponding to the tomcat version) Put log4j-1.2.17.jar and tomcat-juli-adapters.jar in $CATALINA_HOME/lib; replace $CATALINA_HOME/bin/tomcat-juli.jar with the newly downloaded tomcat-juli.jar. Delete $CATALINA_BASE/conf/logging.properties. Restart tomcat About the default catalina log format If you only want to change the default log format of Tomcat, just replace the default java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter Change it to the following: java.util.logging.ConsoleHandler.formatter = com.xxx.LogFormatter org.apache.juli.FileHandler.formatter = com.xxx.LogFormatter Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: MySQL Oracle and SQL Server paging query example analysis
>>: How to use physics engine joints in CocosCreator
Data Sheet /* Navicat SQLite Data Transfer Source...
Table of contents Scenario Analysis Development S...
The first step is to unzip the compressed package...
As shown below: Mainly execute authorization comm...
Install Oracle_11g with Docker 1. Pull the oracle...
Table of contents 1. What is redux? 2. The princi...
This article uses examples to illustrate the impl...
The following is an introduction to using SQL que...
MySQL 5.7 installation We are learning MySQL data...
1. Introduction Our real servers should not be di...
Today I used a virtual machine to do an experimen...
This article mainly introduces the sample code of...
Share a beautiful input box animation style libra...
Whether it is the background image or the text siz...
When uploading on some websites, after clicking t...