Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback pattern exception after converting from log4j

I am currently moving from log4j to logback and i converted my log4j.properties file using the converter they offer in the logback homepage. But i am getting some weird error on my pattern that i cant figure out what it wants me to do:

<?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>

and here is the error i am getting:

18:02:29,368 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@17f9a29 - Failed to instantiate converter class [ch.qos.logback.classic.pattern.MethodOfCallerConverter] as a composite converter for keyword [M] ch.qos.logback.core.util.IncompatibleClassException at ch.qos.logback.core.util.IncompatibleClassException at at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:62) at at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:48) at at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:35) at at ch.qos.logback.core.pattern.parser.Compiler.createCompositeConverter(Compiler.java:135) at at ch.qos.logback.core.pattern.parser.Compiler.compile(Compiler.java:47) at at ch.qos.logback.core.pattern.parser.Parser.compile(Parser.java:91) at at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:86) at at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28) at at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167) at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317) at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196) at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49) at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148) at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85) at at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:55) at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) at at taxonomyParser.(taxonomyParser.java:34) 18:02:29,368 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@17f9a29 - Failed to create converter for [%M] keyword

I dont understand it because on the documentation page they clearly say that %M is the modifier for Method.

Thanks.

like image 848
Gleeb Avatar asked Jan 13 '23 13:01

Gleeb


1 Answers

At the pattern, the parenthesis are special.

Where you coded %M(), try %M\(\).

See at Logback Layouts

like image 61
dudinha-dedalus Avatar answered Jan 21 '23 10:01

dudinha-dedalus