我目前正在从 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 |-ch.qos.logback.core.pattern.parser.Compiler@17f9a29 中的错误-无法将转换器类 [ch.qos.logback.classic.pattern.MethodOfCallerConverter] 实例化为关键字 [ M] ch.qos.logback.core.util.IncompatibleClassException at 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) 在 ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:35) 在 ch.qos.logback.core .pattern.parser.Compiler.createCompositeConverter(Compiler.java:135) 在 ch.qos.logback.core.pattern.parser.Compiler.compile(Compiler.java:47) 在 ch.qos.logback.core.pattern .解析器。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) 在 ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167) 在 ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java: 317) 在 ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196) 在 ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)在 ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62) 在 ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149) 在 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 org。 slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85) 在 org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:55) 在 org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) 在 org .slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) 在 org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) 在 org.slf4j。LoggerFactory.getLogger(LoggerFactory.java:269) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) at taxonomyParser.(taxonomyParser.java:34) 18:02:29,368 |-ch.qos 中的错误。 logback.core.pattern.parser.Compiler@17f9a29 - 无法为 [%M] 关键字创建转换器
我不明白,因为在文档页面上他们清楚地说 %M 是 Method 的修饰符。
谢谢。