I am making use of the <jmxConfigurator/>
element in logback; The jmxConfigurator states the following:
Thus, unless your application is a standalone Java application, you **MUST** unregister the JMXConfigurator instance from the JVM's Mbeans server.
The logback documentation also mentions a <shutdownHook/>
configuration element which according to the documentation does the following:
Installing a JVM shutdown hook is a convenient way for shutting down logback and releasing associated resources.
Does including the <shutdownHook/>
element take care of unregistering the <jmxConfigurator/>
?
Yes, it does. Here is a proof from the debugger:
However, there are a few restrictions:
<shutdownHook/>
is available only as of version 1.1.3<shutdownHook/>
is enough, you have to specify the class
property:
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
otherwise logback complains with: ERROR in ch.qos.logback.core.joran.action.ShutdownHookAction - Missing class name for shutdown hook. Near [shutdownHook] line 16
To make sure that the JMXConfigurator gets stopped enable debug mode on the logback configuration:
<configuration debug="true">
...
</configuration>
Then at the end of your logs you'll see:
INFO in ch.qos.logback.core.hook.DelayingShutdownHook@1a246fc6 - Logback context being closed via shutdown hook INFO in ch.qos.logback.classic.jmx.JMXConfigurator(default) - onReset() method called JMXActivator [ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.JMXConfigurator]
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