从log4j转换后的回归模式异常

时间:2013-08-27 15:04:38

标签: java logging log4j slf4j logback

我目前正从log4j迁移到logback,并使用他们在logback主页中提供的转换器转换了我的log4j.properties文件。但我在模式上得到一些奇怪的错误,我无法弄清楚它想要我做什么:

<?xml version="1.0" encoding="UTF-8"?>
<!-- For assistance related to logback-translator or configuration  -->
<!-- files in general, please contact the logback user mailing list -->
<!-- at http://www.qos.ch/mailman/listinfo/logback-user             -->
<!--                                                                -->
<!-- For professional support please see                            -->
<!--    http://www.qos.ch/shop/products/professionalSupport         --> 
<!--                                                                -->
<configuration>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
  <pattern>%d{ISO8601} [%p] [%C{1},%M(),%L] - %m%n</pattern>
</encoder>
</appender>
<appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--See also http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
<File>/log/debug.log</File>
<encoder>
  <pattern>%d{ISO8601} %15.15t [%p] [%C{1},%M():%L] - %m%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
  <maxIndex>1</maxIndex>
  <FileNamePattern>/log/debug.log.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  <MaxFileSize>100KB</MaxFileSize>
</triggeringPolicy>
</appender>
<root level="debug">
<appender-ref ref="stdout"/>
<appender-ref ref="R"/>
</root>
</configuration>

这是我得到的错误:

  

18:02:29,368 | -ERROR in ch.qos.logback.core.pattern.parser.Compiler@17f9a29 - 无法将转换器类[ch.qos.logback.classic.pattern.MethodOfCallerConverter]实例化为复合转换器for keyword [M] ch.qos.logback.core.util.IncompatibleClassException       在ch.qos.logback.core.util.IncompatibleClassException       at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:62)       at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:48)       at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:35)       at ch.qos.logback.core.pattern.parser.Compiler.createCompositeConverter(Compiler.java:135)       at ch.qos.logback.core.pattern.parser.Compiler.compile(Compiler.java:47)       at ch.qos.logback.core.pattern.parser.Parser.compile(Parser.java:91)       at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:86)       at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28)       at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167)       at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)       at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)       at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)       at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)       at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)       at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)       at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)       at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)       at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)       at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)       at atg.slf4j.impl.StaticLoggerBinder.init(staticLoggerBinder.java:85)       at org.slf4j.impl.StaticLoggerBinder。(staticLoggerBinder.java:55)       在org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)       在org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)       at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)       at atg.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)       at atg.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)       at taxonomyParser。(taxonomyParser.java:34)   18:02:29,368 | -ERROR in ch.qos.logback.core.pattern.parser.Compiler@17f9a29 - 无法为[%M]关键字创建转换器

我不理解它,因为在文档页面上他们清楚地说%M是Method的修饰符。

感谢。

1 个答案:

答案 0 :(得分:5)

在模式中,括号是特殊的。

您对%M()进行了编码,请尝试%M\(\)

Logback Layouts