posts - 22, comments - 17, trackbacks - 0, articles - 15
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

tomcat5.5日志

Posted on 2007-01-09 18:42 码农cz 阅读(1396) 评论(0)  编辑  收藏 所属分类: As u
自从用上了tomcat5.5,发现日志信息没了,出错了也找不着有用的信息,上apache找答案,果然

Tomcat 5.5 uses Commons Logging throughout its internal code allowing the developer to choose a logging configuration that suits their needs, e.g java.util.logging or Log4J. Commons Logging provides Tomcat the ability to log hierarchially across various log levels without needing to rely on a particular logging implementation.

An important consequence for Tomcat 5.5 is that the <Logger> element found in previous versions to create a localhost_log is no longer a valid nested element of <Context>. Instead, the default Tomcat configuration will use java.util.logging. If the developer wishes to collect detailed internal Tomcat logging (i.e what is happening within the Tomcat engine), then they should configure a logging system such as java.util.logging or log4j as detailed next

习惯用log4j来配置log信息的输出。

新建log4j.properties,内容为

log4j.rootLogger=info,Console,R

log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
#log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.Console.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n

log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy.MM.dd HH:mm:ss} %5p %c{1}(%L):  %m%n

log4j.logger.org.apache=info, R
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, R
log4j.logger.org.apache.catalina.core=info, R
log4j.logger.org.apache.catalina.session=info, R

最后四行是tomcat的信息,如果改为debug日志文件将十分庞大。

将这个文件放入${catalina.home}/common/classes下,再将log4j.jar和commons-logging.jar放入${catalina.home}/common/lib下,就可以在${catalina.home}/logs/下见到日志了。


只有注册用户登录后才能发表评论。


网站导航: