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 <wo...@adobe.com> on 2005/02/01 18:19:38 UTC
RE: Watchdogs
Well, my prediction was wrong. If I call JoranConfigurator subsequent
times, each time using a config file that does not duplicate previous
appenders, etc, then I do not get the double logging. Cool.
So, I started looking at doing my own ResetConfigurationAction class and
attaching it to the JoranConfigurator. However, I think there will be some
issues with this.
I wrote the action to perform a resetConfiguration(), instead of a
shutdown(). That seemed a better choice for what it is trying to
accomplish. But, if I do this while Joran is parsing or replaying the
events, it will have the effect of removing any temporary appenders that are
attached, such as the list appender that Joran attaches. The internal
console appender that the ConfigurationAction attaches, when the "debug"
attribute is true, appears to be unharmed.
I also tried it by modifying the ConfigurationAction to recognize a "reset"
attribute, but since the resetConfiguration() is happening in an action,
after the JoranConfigurator has attached the list appender, that appender
still gets removed.
Either way, I get an error message saying the list appender cannot be found.
I did not have a chance to look at it in detail yet. What is this list
appender used for?
-Mark
> -----Original Message-----
> From: Ceki Gülcü [mailto:ceki@qos.ch]
> Sent: Monday, January 31, 2005 12:12 PM
> To: Log4J Developers List
> Subject: RE: Watchdogs
>
> At 08:54 PM 1/31/2005, you wrote:
> >Adding a reset-configuration action sounds like a good thing to have.
> I'll
> >look into adding it; it will be a good chance to play with Joran.
> >
> >But I am still curious as to why the JoranConfigurator starts with the
> >double logging messages right from the very start of the second
> doConfigure:
>
> That's internal-logging "magic".
>
> Hint: Joran is replaying events... See also
> ConfiguratorBase.attachListAppender and detachListAppender methods and how
> they are used in JoranConfigurator.doConfigure(ParseAction,
> LoggerRepository) method.
>
> By the way, PropertyConfigurator does exactly the same.
>
> [cut]
>
> >I'll play with it this evening and see.
>
> Alright.
>
> >Thanks,
> >-Mark
>
> --
> Ceki Gülcü
>
> The complete log4j manual: http://www.qos.ch/log4j/
>
>
>
> ---------------------------------------------------------------------
> 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
RE: Watchdogs
Posted by Ceki Gülcü <ce...@qos.ch>.
At 06:19 PM 2/1/2005, Mark Womack wrote:
>Well, my prediction was wrong. If I call JoranConfigurator subsequent
>times, each time using a config file that does not duplicate previous
>appenders, etc, then I do not get the double logging. Cool.
>
>So, I started looking at doing my own ResetConfigurationAction class and
>attaching it to the JoranConfigurator. However, I think there will be some
>issues with this.
>
>I wrote the action to perform a resetConfiguration(), instead of a
>shutdown().
The fact that Hierarchy has two methods, shutdown and resetConfiguration()
both performing the same action, a very important one at that, is not good.
The resetConfiguration() method should not exist.
>That seemed a better choice for what it is trying to
>accomplish. But, if I do this while Joran is parsing or replaying the
>events, it will have the effect of removing any temporary appenders that are
>attached, such as the list appender that Joran attaches. The internal
>console appender that the ConfigurationAction attaches, when the "debug"
>attribute is true, appears to be unharmed.
The temporary ConsoleAppender should be closed and detached as any other
appender. If it isn't closed then there is a bug in the
Hierarchy.resetConfiguration() method.
>I also tried it by modifying the ConfigurationAction to recognize a "reset"
>attribute, but since the resetConfiguration() is happening in an action,
>after the JoranConfigurator has attached the list appender, that appender
>still gets removed.
>
>Either way, I get an error message saying the list appender cannot be found.
>I did not have a chance to look at it in detail yet. What is this list
>appender used for?
That is what I tried to explain in my last message.
Joran uses the list appender to replay events. See also
ConfiguratorBase.attachListAppender and detachListAppender methods and how
they are used in JoranConfigurator.doConfigure(ParseAction,
LoggerRepository) method.
What you need to do in your ResetAction is to detach the temporary console
appender (if it exists) and the temporary list appender, and re-attach them
after resetting the environment. You can detach an appender by calling
removeAppender(String) on the appropriate logger. Note that the
Category.removeAppender(String) method does NOT close the appender being
removed.
>-Mark
--
Ceki Gülcü
The complete log4j manual: http://www.qos.ch/log4j/
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org