logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Mayne <mich...@michaelmayne.me.uk>
Subject Appender Close() not being called when application ends
Date Fri, 06 Feb 2009 09:50:56 GMT

I'm creating a custom AsyncAppender() that buffers synchronous event appends
, using an internal dequeue thread to process these buffered events sending
them onto attached appenders. The internal workings are not important to my
problem (I think)... 


What I'm seeing is that neither the Close() or ~AsyncAppender() (finalize)
methods are being called when my test program attempts to exit i.e. my test
program hangs. This is important because my class cleanup triggers the
dequeue thread to drain any buffered events, terminate the thread and
dispose. If not triggered the dequeue thread sits there waiting on an
autoReset event for ever - hence the program hang.


However, If I explicitly shutdown the repository, Close() is called and it
all works perfectly.




AsyncAppender inherits AppenderSkeleton so overrides OnClose(). It also
implements IDisposable using the classic Dispose pattern.

My test program is configuring everything programmatically (no config files)
so I can see what's going on - well that was the idea J


I would have thought that when my program exited, Log4net would be garbage
collected and my Close() (or destructor) method would be called.


What am I doing wrong?


I can include some code later but I really want to get an idea of the
appender lifecycle.





View raw message