How to wait for AsyncAppender to finish all its tasks?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to wait for AsyncAppender to finish all its tasks?

silentspring
This post has NOT been accepted by the mailing list yet.
Hello everyone,

I am newbie to log4cxx. I am playing with AsyncAppender and feel it is really beneficial in terms of performance. I notice that when AsyncAppender starts working, a new thread is created for dispatching the messages so that the main thread will not be blocking for file writing.

My question is how to wait for the all the AsyncAppenders to finish their work. For example  the main thread want to quit right now and before it quits I want to make sure all the pending file writing finished by the AsyncAppenders. I know that AsyncAppender has close method which will wait for the dispatch thread to finish its work. But in case there are a few AsyncAppenders working for a few loggers and I did not record the LoggerPtr and the AppenderPtr in anywhere (the loggers and appenders are all configured by xml file). Does log4cxx support an API to uninitialise the log4cxx so that everything is cleaned up gracefully?

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to wait for AsyncAppender to finish all its tasks?

silentspring
This post has NOT been accepted by the mailing list yet.
Finally I realised that this is a very stupid question.
The LogManager::shutdown() can do all the cleanup work for me.

Thanks all the same. :-)
Loading...