[logback-user] log4j to logback translation issues - $ char in logger name, and rolling policy

Ceki Gulcu ceki at qos.ch
Fri Mar 4 17:01:54 UTC 2016


Hi Stevo,

Both '.' and '$' are recognized as legitimate separator characters in 
logger names. What you are describing looks like a bug in LoggerAction, 
in particular variable substitution. Can you please create a bug report 
including the stack trace below and the configuration snippet <logger/>?

--
Ceki


On 3/4/2016 16:53, Stevo Slavić wrote:
> Hello Logback community,
>
> I converted Apache Kafka log4j.properties to logback.xml using
> http://logback.qos.ch/translator/
>
> Translator didn't report invalid '$' char in logger name, only when
> running app, logback threw exception:
>
> 16:07:38,628 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter at 701:80
> - RuntimeException in Action for tag [logger]
> java.lang.IllegalArgumentException: Failed to parse input
> [kafka.network.RequestChannel$]
>      at java.lang.IllegalArgumentException: Failed to parse input
> [kafka.network.RequestChannel$]
>      at     at
> ch.qos.logback.core.util.OptionHelper.substVars(OptionHelper.java:114)
>      at     at
> ch.qos.logback.core.joran.spi.InterpretationContext.subst(InterpretationContext.java:157)
>      at     at
> ch.qos.logback.classic.joran.action.LoggerAction.begin(LoggerAction.java:44)
>      at     at
> ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:269)
>      at     at
> ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:145)
>      at     at
> ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:128)
>      at     at
> ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
>      at     at
> ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:148)
>      at     at
> ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
>      at     at
> ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:100)
>      at     at
> ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:50)
>      at     at
> ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
>      at     at
> ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
>      at     at
> org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
>      at     at
> org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
>      at     at org.slf4j.LoggerFactory.bind(LoggerFactory.java:147)
>      at     at
> org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:122)
>      at     at
> org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:378)
>      at     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:328)
>      at     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:349)
>      at     at org.apache.kafka.common.utils.Utils.<clinit>(Utils.java:54)
>      at     at kafka.Kafka$.getPropsFromArgs(Kafka.scala:41)
>      at     at kafka.Kafka$.main(Kafka.scala:57)
>      at     at kafka.Kafka.main(Kafka.scala)
> Caused by: ch.qos.logback.core.spi.ScanException: Unexpected end of
> pattern string
>      at     at
> ch.qos.logback.core.subst.Tokenizer.tokenize(Tokenizer.java:70)
>      at     at
> ch.qos.logback.core.subst.NodeToStringTransformer.tokenizeAndParseString(NodeToStringTransformer.java:53)
>      at     at
> ch.qos.logback.core.subst.NodeToStringTransformer.substituteVariable(NodeToStringTransformer.java:46)
>      at     at
> ch.qos.logback.core.util.OptionHelper.substVars(OptionHelper.java:112)
>      at     ... 23 common frames omitted
>
> Should $ char be allowed in logger name? In other words is it bug in
> configuration if one uses it or is it bug in logback that it doesn't
> handle it well? I'm using logback 1.7.18.
>
>
> Secondly, translator had problems converting data pattern like:
>
> log4j.appender.kafkaAppender=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.kafkaAppender.DatePattern='.'yyyy-MM-dd-HH
> log4j.appender.kafkaAppender.File=${kafka.logs.dir}/server.log
>
> it converted that to
>
> ...
>      <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
>
> <fileNamePattern>${kafka.logs.dir}/server.log.%d{'.'yyyy-MM-dd-HH}</fileNamePattern>
>      </rollingPolicy>
> ...
>
> where Logback complained about that dot '.' in fileNamePattern as invalid.
>
>
> Lastly, it seems in Logback specification when to roll (e.g. daily) and
> what should be format and info included in the file name are tightly
> coupled.
>
> Kind regards,
> Stevo Slavic.
>
>
> _______________________________________________
> logback-user mailing list
> logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>


More information about the logback-user mailing list