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

Stevo Slavić sslavic at gmail.com
Fri Mar 4 15:53:38 UTC 2016


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20160304/7c84d5a0/attachment.html>


More information about the logback-user mailing list