You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Mark Womack <mw...@apache.org> on 2005/01/31 04:31:32 UTC

JoranConfigurator Bug?

Looking at the behavior I am seeing with my FileWatchdogTestCase, I think 
there is a bug in JoranConfigurator or there is something new I don't 
understand here.

If I just have this code:

      Configurator configurator = new JoranConfigurator();
      configurator.doConfigure(configURL, LogManager.getLoggerRepository());
      configurator = new JoranConfigurator();
      configurator.doConfigure(configURL, LogManager.getLoggerRepository());

(configURL is set to a file that has contents of 
input/watchdog/watchdog.FileWatchdog.test1_1.xml)

after the first doConfigure call, the output log has the following (correct) 
contents:

DEBUG - Ignoring debug attribute.
DEBUG - About to instantiate appender of type 
[org.apache.log4j.FileAppender]
DEBUG - Appender named as [A1]
DEBUG - Pushing appender on to the object stack.
DEBUG - In ParamAction setting parameter [Append] to value [true].
DEBUG - In ParamAction setting parameter [File] to value 
[output/watchdog.FileWatchdog.test1.txt].
DEBUG - About to instantiate layout of type [org.apache.log4j.PatternLayout]
DEBUG - Pushing layout on top of the object stack.
DEBUG - In ParamAction setting parameter [ConversionPattern] to value [%p - 
%m%n].
DEBUG - Popping layout from the object stack
DEBUG - About to set the layout of the containing appender.
DEBUG - setFile called: output/watchdog.FileWatchdog.test1.txt, true
DEBUG - setFile ended
DEBUG - Popping appender named [A1] from the object stack
DEBUG - Logger name is [org.apache.log4j.watchdog.FileWatchdogTestCase].
DEBUG - Retreiving an instance of org.apache.log4j.getLogger().
DEBUG - Setting [org.apache.log4j.watchdog.FileWatchdogTestCase] additivity 
to [true].
DEBUG - Pushing logger named 
[org.apache.log4j.watchdog.FileWatchdogTestCase].
DEBUG - Encapsulating logger name is 
[org.apache.log4j.watchdog.FileWatchdogTestCase], levelvalue is  [debug].
DEBUG - org.apache.log4j.watchdog.FileWatchdogTestCase level set to DEBUG
DEBUG - end() called.
DEBUG - Removing logger from stack.
DEBUG - Pushing root logger on stack
DEBUG - Attaching appender named [A1] to logger named [root].
DEBUG - Encapsulating logger name is [root], levelvalue is  [debug].
DEBUG - root level set to DEBUG
DEBUG - Removing root logger from top of stack.
DEBUG - Finished parsing.

But, when the second doConfigure is called, then the output log starts to 
get double output like this:

DEBUG - Ignoring debug attribute.
DEBUG - Ignoring debug attribute.
DEBUG - About to instantiate appender of type 
[org.apache.log4j.FileAppender]
DEBUG - About to instantiate appender of type 
[org.apache.log4j.FileAppender]
DEBUG - Appender named as [A1]
DEBUG - Appender named as [A1]
DEBUG - Pushing appender on to the object stack.
DEBUG - Pushing appender on to the object stack.
...

So, what I thought was being caused by having 2 A1 file appenders cannot be 
as the second file appender has not been configured yet.  The double output 
is happening as soon as the JoranConfigurator starts the second doConfigure. 
If I do another doConfigure, I get triple output.

Is there something I am supposed to do here that is new or I am forgetting?

-Mark




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: JoranConfigurator Bug?

Posted by Mark Womack <mw...@apache.org>.
As another data point, if I have the same code using PropertyConfigurator, 
there is no double logging.

      Configurator configurator = new PropertyConfigurator();
      configurator.doConfigure(configURL, LogManager.getLoggerRepository());
      onfigurator = new PropertyConfigurator();
      configurator.doConfigure(configURL, LogManager.getLoggerRepository());

and the config file looks like:

log4j.debug=TRUE
log4j.threshold=ON
log4j.rootLogger=DEBUG,A
log4j.appender.A=org.apache.log4j.FileAppender
log4j.appender.A.File=output/watchdog.FileWatchdog.test2.txt
log4j.appender.A.Append=true
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%p - %m%n

log4j.logger.org.apache.log4j.watchdog.FileWatchdogTestCase=DEBUG

-Mark

----- Original Message ----- 
From: "Mark Womack" <mw...@apache.org>
To: "Log4J Developers List" <lo...@logging.apache.org>
Sent: Sunday, January 30, 2005 7:31 PM
Subject: JoranConfigurator Bug?


> Looking at the behavior I am seeing with my FileWatchdogTestCase, I think 
> there is a bug in JoranConfigurator or there is something new I don't 
> understand here.
>
> If I just have this code:
>
>      Configurator configurator = new JoranConfigurator();
>      configurator.doConfigure(configURL, 
> LogManager.getLoggerRepository());
>      configurator = new JoranConfigurator();
>      configurator.doConfigure(configURL, 
> LogManager.getLoggerRepository());
>
> (configURL is set to a file that has contents of 
> input/watchdog/watchdog.FileWatchdog.test1_1.xml)
>
> after the first doConfigure call, the output log has the following 
> (correct) contents:
>
> DEBUG - Ignoring debug attribute.
> DEBUG - About to instantiate appender of type 
> [org.apache.log4j.FileAppender]
> DEBUG - Appender named as [A1]
> DEBUG - Pushing appender on to the object stack.
> DEBUG - In ParamAction setting parameter [Append] to value [true].
> DEBUG - In ParamAction setting parameter [File] to value 
> [output/watchdog.FileWatchdog.test1.txt].
> DEBUG - About to instantiate layout of type 
> [org.apache.log4j.PatternLayout]
> DEBUG - Pushing layout on top of the object stack.
> DEBUG - In ParamAction setting parameter [ConversionPattern] to value 
> [%p - %m%n].
> DEBUG - Popping layout from the object stack
> DEBUG - About to set the layout of the containing appender.
> DEBUG - setFile called: output/watchdog.FileWatchdog.test1.txt, true
> DEBUG - setFile ended
> DEBUG - Popping appender named [A1] from the object stack
> DEBUG - Logger name is [org.apache.log4j.watchdog.FileWatchdogTestCase].
> DEBUG - Retreiving an instance of org.apache.log4j.getLogger().
> DEBUG - Setting [org.apache.log4j.watchdog.FileWatchdogTestCase] 
> additivity to [true].
> DEBUG - Pushing logger named 
> [org.apache.log4j.watchdog.FileWatchdogTestCase].
> DEBUG - Encapsulating logger name is 
> [org.apache.log4j.watchdog.FileWatchdogTestCase], levelvalue is  [debug].
> DEBUG - org.apache.log4j.watchdog.FileWatchdogTestCase level set to DEBUG
> DEBUG - end() called.
> DEBUG - Removing logger from stack.
> DEBUG - Pushing root logger on stack
> DEBUG - Attaching appender named [A1] to logger named [root].
> DEBUG - Encapsulating logger name is [root], levelvalue is  [debug].
> DEBUG - root level set to DEBUG
> DEBUG - Removing root logger from top of stack.
> DEBUG - Finished parsing.
>
> But, when the second doConfigure is called, then the output log starts to 
> get double output like this:
>
> DEBUG - Ignoring debug attribute.
> DEBUG - Ignoring debug attribute.
> DEBUG - About to instantiate appender of type 
> [org.apache.log4j.FileAppender]
> DEBUG - About to instantiate appender of type 
> [org.apache.log4j.FileAppender]
> DEBUG - Appender named as [A1]
> DEBUG - Appender named as [A1]
> DEBUG - Pushing appender on to the object stack.
> DEBUG - Pushing appender on to the object stack.
> ...
>
> So, what I thought was being caused by having 2 A1 file appenders cannot 
> be as the second file appender has not been configured yet.  The double 
> output is happening as soon as the JoranConfigurator starts the second 
> doConfigure. If I do another doConfigure, I get triple output.
>
> Is there something I am supposed to do here that is new or I am 
> forgetting?
>
> -Mark
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org