logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <...@qos.ch>
Subject Re: AW: Changing log4j config on the fly with 'configureAndWatch()'
Date Fri, 08 Jun 2001 08:29:16 GMT

OK, that makes sense. 

Here are some relevant rules.

0) When reading a new config file, the existing log4j configuration is not reset. 

1) See rule 0.

3) Whenever a category element is seen in the config file, then all the existing appenders
for THAT category are closed and then removed from the category. After that, any appenders
referenced by the category element are parsed and initialized if they haven't been previously.

4) From rule 0, it follows that existing categories that are not mentioned in the config file
remain untouched.

5) Did I mention rule 1?

In your case, a.b.c.myclass.foo and a.b.c.myclass.foo.doo are referring to a closed instance
of CMD. The category element for a.b.c.myclass caused CMD to be closed and opened again.

By the way, why are setting the additivity for a.b.c.myclass.foo and a.b.c.myclass.foo.doo
to false? Why don't you let them inherit CMD from a.b.c.myclass? Hope this helps, Ceki

At 09:29 08.06.2001 +0200, you wrote:
>Hi Paul (and the others),
>this my log4j.xml file. During runtime i removed the 2 outcommenting lines. 
>And later, i commented out again these category declarations.
>As i said, log4j recognize the new declarations during runtime, but has a
>problem when i 'remove' them during runtime.
>log4j:ERROR Attempted to append to closed appender named [CMD].
>log4j:WARN Not allowed to write to a closed appender.
><?xml version="1.0" encoding="UTF-8" ?>
><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
><log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' >
><appender name="CMD" class="org.apache.log4j.ConsoleAppender">
>    <param name="Threshold" value="INFO"/>
>    <layout class="org.apache.log4j.PatternLayout">
>        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p
>%-35c %M() > %m%n"/>
>    </layout>
><category name="a.b.c.myclass" additivity="false">
>    <priority value="WARN" />
>    <appender-ref ref="CMD" />
><category name="a.b.c.myclass.foo" additivity="false">
>    <priority value="INFO" />
>    <appender-ref ref="CMD" />
><category name="a.b.c.myclass.foo.doo" additivity="false">
>    <priority value="DEBUG" />
>    <appender-ref ref="CMD" />
>-----Ursprungliche Nachricht-----
>Von: Paul Glezen [mailto:pglezen@atdial.net]
>Gesendet: Freitag, 8. Juni 2001 07:19
>An: LOG4J Users Mailing List
>Betreff: Re: Changing log4j config on the fly with 'configureAndWatch()'
>Could you provide a snipet of the configuration file indicating the
>entries you added and then took out.
>- Paul
>Beware of bugs in the above code.  I have
>only proved it correct, not tried it.
>-Don Knuth
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

Ceki Gülcü

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

View raw message