tomcat7 log4j配置一部分日志还在catalina.out输出

我按照网上配置在tomcat配置了log4j,一部分日志是按我配置那样输出的,但是有一部分日志还是写入catalina.out,不知道为什么,我看了主要是线程调用的类输出的日志。
有谁知道原因吗?

步骤如下:
1. 把log4j-1.2.17.jar,tomcat-juli.jar,tomcat-juli-adapters.jar拷贝到tomcate目录/ lib下
2. 把tomcat-juli.jar拷贝到tomcate目录/ bin下,并覆盖原来的tomcat-juli.jar
3. 在tomcate目录/ lib下(例如/tomcat/apache-tomcat-7.0.59/lib)新建一个文件log4j.properties,并添加如下内容
log4j.rootLogger=INFO, CATALINA

Define all the appenders

log4j.appender.CATALINA=org.apache.log4j.RollingFileAppender
log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.
log4j.appender.CATALINA.MaxFileSize=50MB
log4j.appender.CATALINA.MaxBackupIndex=100

log4j.appender.CATALINA.Append=true
log4j.appender.CATALINA.Encoding=GBK

Roll-over the log once per day

log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd-HH-mm'.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=GBK
log4j.appender.LOCALHOST.DatePattern='.'yyyy-MM-dd-HH'.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=GBK
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=GBK
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=GBK
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

  1. 在tomcate目录/ conf下(例如/tomcat/apache-tomcat-7.0.59/conf)打开context.xml,把修改为
  2. 删除 Tomcat 的/tomcat/apache-tomcat-7.0.59/conf/logging.properties 文件(或者重命名-建议)

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐