- Create a file called log4j.properties with the following content and save it into common/classes.




log4j.rootLogger=INFO,R log4j.appender.R=org.apache.log4j.DailyRollingFileAppender log4j.appender.R.File=${catalina.home}/logs/tomcat.log log4j.appender.MANAGER.Append=true log4j.appender.MANAGER.Encoding=UTF-8 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern = [%d] [%t] [%-5p] [%c] -%m%n




- Download Log4J (v1.2 or later) and place the log4j jar in $CATALINA_HOME/common/lib.
- Download Commons Logging and place the commons-logging-x.y.z.jar (not commons-logging-api-x.y.z.jar) in $CATALINA_HOME/common/lib with the log4j jar.
- Start Tomcat
Using Log4j in Tomcat 5.5.x
本文详细介绍了如何在使用Log4J和Tomcat的环境中配置日志系统,包括创建log4j.properties文件、下载并放置相关库、以及启动Tomcat的过程。旨在帮助开发者了解和实施有效的日志管理。

被折叠的 条评论
为什么被折叠?



