在log4j中扩展PatternLayout时出现问题

时间:2015-06-23 15:29:09

标签: java tomcat logging log4j classloader

我创建了一个新类NewLinePatternLayout.java,它扩展了log4j的PatternLayout.java。下面是我的log4j.properties。

log4j.rootLogger=INFO, R 
log4j.appender.R=org.apache.log4j.RollingFileAppender 
log4j.appender.R.File=${catalina.home}/logs/tomcat.log 
log4j.appender.R.MaxFileSize=10MB 
log4j.appender.R.MaxBackupIndex=10 
log4j.appender.R.layout=com.myCompany.utils.NewLinePatternLayout  
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

我收到如下错误:

    log4j:ERROR The class "org.apache.log4j.Layout" was loaded by 
log4j:ERROR [WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@620a3d3b
] whereas object of type 
log4j:ERROR "com.myCompany.utils.NewLinePatternLayout" was loaded by [org.apache.catalina.loader.StandardClassLoader@620a3d3b].
log4j:ERROR No layout set for the appender named [R].
log4j:ERROR A "com.myCompany.utils.NewLinePatternLayout" object is not assignable to a "org.apache.log4j.Layout" variable.
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by 
log4j:ERROR [WebappClassLoader

请告知如何解决这个问题?

0 个答案:

没有答案