[logback-user] "#logback.classic pattern:" spam in 1.0.2

ceki ceki at qos.ch
Wed May 2 10:31:46 CEST 2012


Hi Benoit,

My response can be found below.

On 02.05.2012 09:53, tsuna wrote:
> Hi list,
> I just upgraded from logback-{core,classic} 1.0.0 to 1.0.2 and now
> whenever I start my application I see a message like this one:
>
> #logback.classic pattern: %msg%n
>
> in my logs.  Like, really, it's literally logging the format string
> itself.  Has a debug statement slipped in the 1.0.2 release?
> Here's the configuration of the app, in case you need it:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration>
>    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
>      <encoder>
>        <pattern>
>          %d{ISO8601} %-5level [%thread] %logger{0}: %msg%n
>        </pattern>
>      </encoder>
>    </appender>
>
>    <appender name="ACCESS"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
>      <file>logs/access.log</file>
>      <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
>        <fileNamePattern>logs/access.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
>        <timeBasedFileNamingAndTriggeringPolicy
> class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
>          <maxFileSize>1GB</maxFileSize>
>        </timeBasedFileNamingAndTriggeringPolicy>
>        <maxHistory>45<!-- days --></maxHistory>
>      </rollingPolicy>
>      <encoder>
>        <pattern>%msg%n</pattern>
>      </encoder>
>    </appender>
>
>    <logger name="access.log" additivity="false">
>      <appender-ref ref="ACCESS"/>
>    </logger>
>    <root level="info">
>      <appender-ref ref="STDOUT"/>
>    </root>
> </configuration>
>
> When I start my app, before my main() starts, I see this on the STDOUT
> console logger:
> #logback.classic pattern: %d{ISO8601} %-5level [%thread] %logger{0}: %msg%n

This can be fixed by telling the PatternLayout not to print the output 
pattern string as a header. Here is the modified ConsoleAppender definition.

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
   <encoder>
     <pattern>%d{ISO8601} %-5level [%thread] %logger{0}: %msg%n</pattern>

    <-- do not print pattern as a header -->
    <outputPatternAsPresentationHeader>
      false
    </outputPatternAsPresentationHeader>
   </encoder>
</appender>

> And this gets added to my logs/access.log:
> #logback.classic pattern: %msg%n

Here is the modified RollingFileAppender defintion:

<appender name="ACCESS"
           class="ch.qos.logback.core.rolling.RollingFileAppender">
   <file>access.log</file>
   <rollingPolicy
           class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
     <fileNamePattern>access.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
       <timeBasedFileNamingAndTriggeringPolicy
         class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
       <maxFileSize>1GB</maxFileSize>
       </timeBasedFileNamingAndTriggeringPolicy>
       <maxHistory>45<!-- days --></maxHistory>
   </rollingPolicy>
   <encoder>
     <pattern>%msg%n</pattern>

     <-- do not print pattern as a header -->
     <outputPatternAsPresentationHeader>
       false
     </outputPatternAsPresentationHeader>
    </encoder>
</appender>

HTH,

-- 
Ceki
http://twitter.com/#!/ceki


More information about the Logback-user mailing list