[logback-user] Stopping LoggerContext while using AsyncAppender

David Roussel nabble at diroussel.xsmail.com
Fri Jun 27 08:53:37 CEST 2014

Hi Paresh,

When you ‘kill’ a process, the OS sends the process a signal.  The JVM receives the signal and will begin shutting down the JVM, this includes running ‘shutdown hooks’

You can setup a shutdown hook which shutdown logback.  If would send a link, but I’m off line on the underground writing this.  But if you google for logback shutdown hook, then I’m sure you’ll find an example.  

In this way when you kill your process logback can shutdown cleanly.

Of course if you do ‘kill -9’ then there is no way to do a clean shutdown.



On 25 Jun 2014, at 06:01, Paresh <Pareshpatnaik.mailbox at gmail.com> wrote:

> I am trying to use AsyncAppender in a standalone application which 
> currently uses RollingFileAppender.
> AsyncAppender documentation mentions that ,
> Upon application shutdown or redeploy, AsyncAppender must be stopped in 
> order to stop and reclaim the worker thread and to flush the logging 
> events from the queue. This can be achieved by stopping the LoggerContext 
> which will close all appenders, including any AsyncAppender instances.
> At the time of stoping the application, we use 'kill' command.
> Had it been a web application, i could have written code to stop the 
> LoggerContext from within contextDestroyed() of ServletContextListener.
> So,i would like to know,
> 1. Is it necessary to stop the LoggerContext while using AsyncAppender.
> 2. Wont stopping the application, stop the worker thread and flush logging 
> events in queue
> 3. Any other way it can be performed.
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user

More information about the Logback-user mailing list