Since Tomcat Catalina.out logs are not automatically split,
First, the log partition needs to be wrapped in the vicinity
1. There are three jar packages in the package:
Log4j-1.2.16.jar
Tomcat-juli-adapters.jar
Tomcat-juli.jar
Note: If not TOMCAT7 version, please go to the official website to download the corresponding version of the Tomcat-juli.jar,tomcat-juli-adapters.jar class package,
Download Address: Http://www.apache.org/dist/tomcat in the corresponding version of the Bin/extras path
Second, modify the relevant configuration file
1, modify the ${catalina.home}/conf/context.xml
Modified: <context > For <context swallowoutput= "true" > The only way to complete the stdout of Tomcat to take over.
2. Copy Log4j-1.2.16.jar and Tomcat-juli-adapters.jar to Tomcat's Lib
3, copy Tomcat-juli.jar to ${catalina.home}/bin, in this directory will exist the file, overwrite can
4, establish log4j.properties, and put it into the/lib of Tomcat
The contents of the log4j.properties are as follows: Relevant parameters can be modified as needed
Log4j.rootlogger=info, CATALINA
# Define all the Appenders
Log4j.appender.catalina=org.apache.log4j.dailyrollingfileappender
Log4j.appender.catalina.file=/home/richmail/logs/tomcat/catalina.log
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.localhost=org.apache.log4j.dailyrollingfileappender
Log4j.appender.localhost.file=/home/richmail/logs/tomcat/localhost.log
Log4j.appender.localhost.append=true
Log4j.appender.localhost.encoding=utf-8
Log4j.appender.localhost.datepattern= '. ' Yyyy-mm-dd
Log4j.appender.LOCALHOST.layout = Org.apache.log4j.PatternLayout
Log4j.appender.LOCALHOST.layout.ConversionPattern =%d [%t]%-5p%c-%m%n
Log4j.appender.manager=org.apache.log4j.dailyrollingfileappender
Log4j.appender.manager.file=/home/richmail/logs/tomcat/manager.log
Log4j.appender.manager.append=true
Log4j.appender.manager.encoding=utf-8
Log4j.appender.manager.datepattern= '. ' Yyyy-mm-dd
Log4j.appender.MANAGER.layout = Org.apache.log4j.PatternLayout
Log4j.appender.MANAGER.layout.ConversionPattern =%d [%t]%-5p%c-%m%n
Log4j.appender.host-manager=org.apache.log4j.dailyrollingfileappender
Log4j.appender.host-manager.file=/home/richmail/logs/tomcat/host-manager.log
Log4j.appender.host-manager.append=true
Log4j.appender.host-manager.encoding=utf-8
Log4j.appender.host-manager.datepattern= '. ' Yyyy-mm-dd
Log4j.appender.host-manager.layout = Org.apache.log4j.PatternLayout
Log4j.appender.host-manager.layout.conversionpattern =%d [%t]%-5p%c-%m%n
Log4j.appender.console=org.apache.log4j.consoleappender
Log4j.appender.console.encoding=utf-8
Log4j.appender.CONSOLE.layout = Org.apache.log4j.PatternLayout
Log4j.appender.CONSOLE.layout.ConversionPattern =%d [%t]%-5p%c-%m%n
# Configure which loggers log to which appenders
Log4j.logger.org.apache.catalina.core.ContainerBase. [Catalina]. [Localhost]=info, localhost
Log4j.logger.org.apache.catalina.core.ContainerBase. [Catalina]. [localhost]. [/manager]=\
INFO, MANAGER
Log4j.logger.org.apache.catalina.core.ContainerBase. [Catalina]. [localhost]. [/host-manager]=\
INFO, Host-manager
5. Modify Bin/catalina.sh
A. Block or delete the following:
(1) If [-Z] $CATALINA _out "]; Then
catalina_out= $CATALINA _base/logs/catalina.out fi
(2) Touch "$CATALINA _out"
(3) >> "$CATALINA _out" 2>&1 "&" (two places)
B. Modifying Org.apache.catalina.startup.Bootstrap "$@" Start \ Content (two places)
Modified to: Org.apache.catalina.startup.Bootstrap "$@" Start & \
6. Modify the Localhost_access_log log path in Conf/server.xml
<valve classname= "Org.apache.catalina.valves.AccessLogValve" directory= "/home/richmail/logs/tomcat"
prefix= "Localhost_access_log" suffix= ". txt"
pattern= "%h%l%u%t "%r" %s%b "/>
7. Delete the Conf/logging.properties file 8. Start Tomcat.