As indicated in [1], whenever a change is detected, the ReconfigureOnChangeFilter resets the logger context which will have the affect of stopping and removing that ReconfigureOnChangeFilter. A new ReconfigureOnChangeFilter will be created as a result of reloading the configuration file. So there is only one ReconfigureOnChangeFilter active at a time.

Here are some relevant lines from [1]:

13:59:57,209 |-INFO in c.q.l.c.turbo.ReconfigureOnChangeFilter@63066306 - Detected change in [[c:\tmp\logging\logback.xml]] 13:59:57,209 |-INFO in c.q.l.c.turbo.ReconfigureOnChangeFilter@63066306 - Will reset and reconfigure context named [bitmole] 13:59:57,224 |-INFO in c.q.l.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeFilter scanning period to 8 seconds 13:59:57,224 |-INFO in c.q.l.c.turbo.ReconfigureOnChangeFilter@f280f28 - Will scan for changes in [[c:\tmp\logging\logback.xml]] every 8 seconds.

I hope this helps,

--
Ceki

[1] http://old.nabble.com/file/p32099960/logback-debug-2.log logback-debug-2.log

On 20.07.2011 21:06, dunand wrote:

I started playing with Logback yesterday. I use scan="true" because I want an
easy way to modify logging without redeploying my webapp.  I noticed that
each time I modify logback.xml a new ReconfigureOnChangeFilter is created.
After 4 modifications and reloading of logback.xml the logback is reloaded 4
times because each new ReconfigureOnChangeFilter scan and reload the config
file. Also, the logging work correctly. My message are logged one time (not
5 times). My only concern is that a new ReconfigureOnChangeFilter is created
every time the config file is reloaded. What I'm I doing wrong ?


The output from debug="true". I made 4 modifications in the config file.
1 modif : changed level of com.lq from DEBUG to WARN
2 modif : changed scan time from 7 to 8 seconds
3 modif : changed scan time from 8 to 9 seconds
4 modif : changed scan time from 9 to 10 seconds
http://old.nabble.com/file/p32099960/logback-debug-2.log logback-debug-2.log


My logback.xml :
<configuration scan="true" scanPeriod="30 seconds" debug="true">
   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
     <encoder>
       <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} -
%msg%n</pattern>
     </encoder>
   </appender>

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


I use a ServletContextListener to initialize Logback because I want a way to
change the logging configuration without redeploying my webapp. If you have
a better way, I'm open to suggestion :
public void contextInitialized(ServletContextEvent sce) {
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
         try {
           JoranConfigurator configurator = new JoranConfigurator();
           configurator.setContext(lc);
           // the context was probably already configured by default
configuration rules
           lc.reset();
           ServletContext servletContext = sce.getServletContext();

configurator.doConfigure(servletContext.getInitParameter(LOGBACK_CONFIG_FILE_PARAMETER));
         } catch (JoranException je) {
           // StatusPrinter will handle this
         }
}


_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://qos.ch/mailman/listinfo/logback-user

Reply via email to