Is closing log blocked? Write logger jmxConfigurator
I am using an item <jmxConfigurator/>
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 Mbeans server.
The protocol documentation also mentions a config item <shutdownHook/>
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.
Is the item included <shutdownHook/>
in the deregistration order <jmxConfigurator/>
?
+3
source to share
1 answer
Yes Yes. Here's the proof from the debugger:
However, there are several limitations:
-
<shutdownHook/>
available only from version 1.1.3 - although the documentation says simple is
<shutdownHook/>
enough, you must specify a propertyclass
:<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
otherwise logback complains about:ERROR in ch.qos.logback.core.joran.action.ShutdownHookAction - Missing class name for shutdown hook. Near [shutdownHook] line 16
To make sure the JMXConfigurator is stopped, enable debug mode in the log configuration:
<configuration debug="true">
...
</configuration>
Then at the end of your logs, you will 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]
+7
source to share