Tomcat under the use of log4j take over catalina.out log file generation, storage by day, solve catalina.out log file too big problem 1. Prepare jar Package:
Log4j-1.2.17.jar (download from http://www.apache.org/dist/logging/log4j/1.2.17/)
Tomcat-juli.jar,
Tomcat-juli-adapters.jar
(Download from http://www.apache.org/dist/tomcat/tomcat-7/v7.0.52/bin/extras/, select the corresponding branch according to your Tomcat version) 2. Copy the three jar packages above to Tomcat's lib directory;
3. Copy the Tomcat-juli.jar to the Tomcat bin directory and replace the original jar package;
4. To modify Tomcat's Conf/context.xml file, the
(Increase the swallowoutput= "true" property configuration, only in this way to completely take the Tomcat stdout to take over. This step is very important in the official website and the internet to find a lot of information are not mentioned. 5. Delete Tomcat's conf/logging.properties file (or rename-recommend);
6. Create log4j.properties files in Tomcat's lib directory:
Log4j.rootlogger=info, CATALINA
# Define all the Appenders
Log4j.appender.catalina=org.apache.log4j.dailyrollingfileappender
Log4j.appender.catalina.file=${catalina.base}/logs/catalina.
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 '. Log '
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=${catalina.base}/logs/localhost.
Log4j.appender.localhost.append=true
Log4j.appender.localhost.encoding=utf-8
Log4j.appender.localhost.datepattern= '. ' Yyyy-mm-dd '. Log '
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=${catalina.base}/logs/manager.
Log4j.appender.manager.append=true
Log4j.appender.manager.encoding=utf-8
Log4j.appender.manager.datepattern= '. ' Yyyy-mm-dd '. Log '
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=${catalina.base}/logs/host-manager.
Log4j.appender.host-manager.append=true
Log4j.appender.host-manager.encoding=utf-8
Log4j.appender.host-manager.datepattern= '. ' Yyyy-mm-dd '. Log '
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
# 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
7 reboot Tomcat, effect