[logback-user] A new ReconfigureOnChangeFilter at each reload of the config file

Ceki Gulcu ceki at qos.ch
Wed Jul 20 22:29:07 CEST 2011


Hello,
I am looking into this. By the way, what is the value of 
LOGBACK_CONFIG_FILE_PARAMETER?
--
Ceki
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
>          }
> }
>



More information about the Logback-user mailing list