[logback-user] double logging

Sebastien Pennec sebastien at qos.ch
Mon Feb 5 10:51:20 CET 2007


Hello Morgan,

I've checked your configuration file and found a few things that may be worth modifying.

First there was spaces in class names. It is something that might result in 
unexpected behaviour... Moreover, your configuration file uses the ActiveFileName 
attribute. If you are using logback's latest version, or any version newer than 0.6, 
the ActiveFileName option is not available anymore, because of a duplication of 
information with the FileAppender's File option. Thus, the ActiveFileName lines of 
your configuration can just be modified in the way that the paramater name should be 
File and not ActiveFileName, and the option's position should be in the <appender> 
element, not in the <rollingPolicy> element.

I've pasted a modified configuration file at the end of this email.

Now, back to your double logging issue.

Can you post your logback version number?

Do you load the configuration file programmatically, or is it automatically loaded by 
logback? If you load your configuration file from your application, it is necessary 
to call the shutdownAndReset() method on the LoggerContext object to disable the 
automatic default configuration. Here's the code you should use:

LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
lc.shutdownAndReset();
configurator.setContext(lc);
String configFile = "my-logback-config.xml";
configurator.doConfigure(configFile);

Hope this helps,

Sébastien


Modified config file:


<configuration>

   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
     <layout class="ch.qos.logback.classic.PatternLayout">
       <param name="pattern" value="%-4relative [%thread] %-5level %class - %msg%n" />
     </layout>
   </appender>

   <appender name="bitranlog" class="ch.qos.logback.core.rolling.RollingFileAppender">
     <param name="File" value="/var/log/smartcorridors/bitran.log" />
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <param name="FileNamePattern" value="bitran_%d{yyyy-MM}.log.gz" />
      </rollingPolicy>

     <layout class="ch.qos.logback.classic.PatternLayout">
       <param name="pattern" value="%-4relative [%thread] %-5level %class - %msg%n" />
     </layout>
   </appender>

   <logger name="org.accma.concentrator.services.bitran.BiTranService">
     <level value="debug"/>
     <appender-ref ref="bitranlog"/>
   </logger>

   <appender name="soccslog" class="ch.qos.logback.core.rolling.RollingFileAppender">
     <param name="File" value="/var/log/smartcorridors/soccs.log" />
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <param name="FileNamePattern" value="soccs_%d{yyyy-MM}.log.gz" />
      </rollingPolicy>

     <layout class="ch.qos.logback.classic.PatternLayout">
       <param name="pattern" value="%-4relative [%thread] %-5level %class - %msg%n" />
     </layout>
   </appender>

   <logger name="org.accma.concentrator.services.soccs.SOCCSService">
     <level value="debug"/>
     <appender-ref ref="soccslog"/>
   </logger>

   <root>
     <level value="debug" />
     <appender-ref ref="STDOUT" />
   </root>

</configuration>







Morgan Smith wrote:
> Greetings,
> 
>  I am seeing double in the  logging. Pretty standard config I think 
> included below. Can't find any references to this problem.
> Wondering if anyone has encountered this.
> 
> 
> Example log output :
> 
> 13161 [AnonymousIoService-1] DEBUG 
> org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable - 
> Exiting since queue is empty for /192.168.22.11:4001
> 13161 [AnonymousIoService-1] DEBUG 
> org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable - 
> Exiting since queue is empty for /192.168.22.11:4001
> 
> 
> any help appreciated,
> 
> -Morgan
> 
> 
> 
> logback.properties :
> 
> <configuration>
> 
>   <appender name="STDOUT" class=" ch.qos.logback.core.ConsoleAppender">
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <param name="pattern" value="%-4relative [%thread] %-5level %class 
> - %msg%n" />
>     </layout>
>   </appender>
> 
>   <appender name="bitranlog" 
> class="ch.qos.logback.core.rolling.RollingFileAppender">
>     <rollingPolicy 
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy ">
>        <param name="FileNamePattern" value="bitran_%d{yyyy-MM}.log.gz" />
>        <param name="ActiveFileName" 
> value="/var/log/smartcorridors/bitran.log" />
>      </rollingPolicy>
> 
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <param name="pattern" value="%-4relative [%thread] %-5level %class 
> - %msg%n" />
>     </layout>
>   </appender>
> 
>   <logger name="org.accma.concentrator.services.bitran.BiTranService">
>     <level value="debug"/>
>     <appender-ref ref="bitranlog"/>
>   </logger>
> 
>   <appender name="soccslog" 
> class="ch.qos.logback.core.rolling.RollingFileAppender">
>     <rollingPolicy 
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy ">
>        <param name="FileNamePattern" value="soccs_%d{yyyy-MM}.log.gz" />
>        <param name="ActiveFileName" 
> value="/var/log/smartcorridors/soccs.log" />
>      </rollingPolicy>
> 
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <param name="pattern" value="%-4relative [%thread] %-5level %class 
> - %msg%n" />
>     </layout>
>   </appender>
> 
>   <logger name="org.accma.concentrator.services.soccs.SOCCSService">
>     <level value="debug"/>
>     <appender-ref ref="soccslog"/>
>   </logger>
> 
>   <root>
>     <level value="debug" />
>     <appender-ref ref="STDOUT" />
>   </root>
> 
> </configuration>
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user

-- 
Sébastien Pennec
sebastien at qos.ch

Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch/



More information about the Logback-user mailing list