We are migrating to logback from log4j for several web apps. In the shutdown of our application we currently call:
org.apache.log4j.LogManager.shutdown();
Which is supposed to flush all async logging and close all external resources (files, sockets).
Is there something similar in logback or does it somehow flush automatically on shutdown?
Mike
It seems that just adding <shutdownHook/>
into configuration should stop the context.
From logback docs:
<configuration>
<!-- in the absence of the class attribute, assume
ch.qos.logback.core.hook.DelayingShutdownHook -->
<shutdownHook/>
....
</configuration>
And from DelayingShutdownHook summary:
ShutdownHook implementation that stops the Logback context after a specified delay. The default delay is 0 ms (zero).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With