[logback-user] how to graceful shutdown logback with AsyncAppenders and without immediateFlush

Gena Makhomed gmm at csdoc.com
Fri Mar 21 12:44:09 CET 2014

On 20.03.2014 22:35, Michael Reinhold wrote:

> The intent of the shutdown hook functionality is not to be a general
> application shutdown hook, but to provide reasonably ways of having
> logback wait for a some condition before shutting down (not just calling
> LoggerContext.stop immediately). Logback can provide one or more general
> mechanisms for performing this action, however if the user's needs
> differ they could implement their own.

Ok. Most likely you are right, such approach is useful for flexibility.
Particularly if exotic appenders are used, like cloud logging services.

And user can select how logback should react to system-wide message
"JVM will be shutdown soon" - by completely shutting down logback
or just by flushing all memory buffers and switching logback
info fail-safe mode and continue logging.

I prefer switching into fail-safe transparent sync mode
to be the default, which guarantee flushing all events
from memory buffers and also allow subsequent events
from other components of system not to be lost
during JVM shutdown sequence.

And only in very exotic situations such default behavior
should be changed by user manually into something else.

Thank you for the good discussion!

Best regards,

More information about the Logback-user mailing list