At 16:12 03.06.2001 -0700, you wrote:
>Ceki Gülcü wrote:
>>
>> At 15:10 03.06.2001 -0700, you wrote:
>> >Mike Papper wrote:
>> >>
>> >> I use the call to Category.shutdown to stop log4j. I have my own appender
>> >> (which is a subclass of RollingFileAppender)
>> >> and want to "rollover" that appender when log4j is shutdown. I cannot seem
>> >> to find a method to override that lets me know when log4j is going away so I
>> >> can initiate a rollover.
>> >>
>> >> Is there a way?
>> >>
>> >> Note that overriding finalize or the close method will not work.
>> >>
>> >> Mike Papper
>> >> [EMAIL PROTECTED]
>> >>
>> >
>> >It looks like the Appender that you are using needs to implement the
>> >org.apache.log4j.spi.AppenderAttachable interface. For some reason
>> >shutdown process only calls the close() method on the Appender if it is
>> >an instance AppenderAttachable. I can't tell you why this is true, but
>> >it is. Maybe someone else on the list can help me understand. Otherwise
>> >I would have to say it's a bug.
>>
>> Hello Mike,
>>
>> You mean Hierarchy.shutdown()? This method closes all appenders. Why
>> do you say that it only closes AppenderAttachables? Regards, Ceki
>>
>>
>
>On line 282 (in the closeNestedAppenders method) of Category.java
>there's a conditional that checks to see if the Appender is an instance
>of AppenderAttachable before it calls the close method. I'm pretty sure
>I got the latest code since I just checked it out last night.
Hello Mike,
Yes, but that is only in closeNestedAppenders.
>You're right it is the Hierarchy.shutdown() method that gets the root
>and any current Categories and then calls the closeNestedAppenders()
>method on each Category, right?
Partially. Nested appenders are closed first, followed by *all* appenders.
Here is the code in Hierarchy.java:
public
void shutdown() {
Category root = getRoot();
// begin by closing nested appenders
root.closeNestedAppenders();
synchronized(ht) {
Enumeration cats = this.getCurrentCategories();
while(cats.hasMoreElements()) {
Category c = (Category) cats.nextElement();
c.closeNestedAppenders();
}
// then, remove all appenders
root.removeAllAppenders();
cats = this.getCurrentCategories();
while(cats.hasMoreElements()) {
Category c = (Category) cats.nextElement();
c.removeAllAppenders();
}
}
}
Does that make better sense? Ceki
>/mike
>
>P.S. I'm new to this list so I hope I am not overstepping my bounds.
ps: Eh, this is the log4j mailing list after all. :-)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]