You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by JEAN-FRANCOIS DAUNE <Da...@IBA.be> on 2002/04/04 10:07:11 UTC

Problem closing and removing AsyncAppender

Hi all,

I have an AsyncAppender appended to the root category.

I have a shutdown thread (registered using Runtime.addShutdownHook) that
must be run when my program exits. In this thread, I log some traces.

As I am in a shutdown process, I don't want the AsyncAppender to be
operational in the shutdown hook (so that I don't have to wait the
AsyncAppender to dump all the events it has buffered). 

I tried to remove the appender by calling
Category.getRoot().removeAppender(myAsyncAppender) and then call
myAsyncAppender.close(). But I does not seem to work, as I see the following
error:

log4j:ERROR Attempted to append to closed appender named [null].

This surprised me, as I explicitly removed the AsyncAppender.

Does anyone known where I was wrong, and how to overcome the problem ???

Thanks & Regards,

J-F Daune

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem closing and removing AsyncAppender

Posted by Ceki Gülcü <ce...@qos.ch>.
Hello Jean-François,

Two possible explanations for the "log4j:ERROR Attempted to append ..." mesage:

1) You have myAsyncAppender attached to multiple loggers.

2) Are you sure myAsyncAppender is really attached to root
and not somewhere else?

BTW, how come your AsyncAppender is not named?

Regards, Ceki

At 10:07 04.04.2002 +0200, JEAN-FRANCOIS DAUNE wrote:
>Hi all,
>
>I have an AsyncAppender appended to the root category.
>
>I have a shutdown thread (registered using Runtime.addShutdownHook) that
>must be run when my program exits. In this thread, I log some traces.
>
>As I am in a shutdown process, I don't want the AsyncAppender to be
>operational in the shutdown hook (so that I don't have to wait the
>AsyncAppender to dump all the events it has buffered).
>
>I tried to remove the appender by calling
>Category.getRoot().removeAppender(myAsyncAppender) and then call
>myAsyncAppender.close(). But I does not seem to work, as I see the following
>error:
>
>log4j:ERROR Attempted to append to closed appender named [null].
>
>This surprised me, as I explicitly removed the AsyncAppender.
>
>Does anyone known where I was wrong, and how to overcome the problem ???
>
>Thanks & Regards,
>
>J-F Daune

--
Ceki
My link of the month: 
http://www.suntimes.com/output/otherviews/cst-edt-ref31.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>