[logback-user] PatternLayout example not working (%PARSER_ERROR_)

Eric Ortéga ericforever at gmail.com
Sat Mar 13 01:34:56 CET 2010


I tried to use PatternLayout in my application, by mimicking the code
in the Chapter 5 of the manual
(http://logback.qos.ch/manual/layouts.html#ClassicPatternLayout) and
kept getting this kind of errors :


I ended up trying to compile the exact same code as in the manual and
in the PatternSample.java example, still getting the same output.

Looking into the sources gave me the idea to set the context of the
layout, which indeed solved the problem :

    PatternLayout layout = new PatternLayout();
    layout.setContext(rootLogger.getLoggerContext()); // <= ADDED THIS LINE
    layout.setPattern("%-5level [%thread]: %message%n");

Before that, I searched a solution to this problem on the net and
didn't find anything relating to it, so I figured I should leave a
message here in case it can help others... I don't know if the problem
originates from a bug in logback or a mistake in the manual, so I post
in the user list. I think it should get fixed, at least in the manual,



More information about the Logback-user mailing list