Interface ShutdownCallbackRegistry
-
- All Known Implementing Classes:
DefaultShutdownCallbackRegistry,Log4jContextFactory
public interface ShutdownCallbackRegistryRegistry used for Runnable shutdown callback instances. Due to differing requirements of how late in the JVM lifecycle Log4j should be shut down, this interface is provided for customizing how to register shutdown hook callbacks. Implementations may optionally implementLifeCycle.- Since:
- 2.1
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSHUTDOWN_CALLBACK_REGISTRYSystem property to set to choose the ShutdownCallbackRegistry.static java.lang.StringSHUTDOWN_HOOK_ENABLEDSystem property to set to override the global ability to register shutdown hooks.static MarkerSHUTDOWN_HOOK_MARKERShared Marker to indicate log messages corresponding to shutdown hooks.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CancellableaddShutdownCallback(java.lang.Runnable callback)Adds a Runnable shutdown callback to this class.
-
-
-
Field Detail
-
SHUTDOWN_CALLBACK_REGISTRY
static final java.lang.String SHUTDOWN_CALLBACK_REGISTRY
System property to set to choose the ShutdownCallbackRegistry.- See Also:
- Constant Field Values
-
SHUTDOWN_HOOK_ENABLED
static final java.lang.String SHUTDOWN_HOOK_ENABLED
System property to set to override the global ability to register shutdown hooks.- See Also:
- Constant Field Values
-
SHUTDOWN_HOOK_MARKER
static final Marker SHUTDOWN_HOOK_MARKER
Shared Marker to indicate log messages corresponding to shutdown hooks.
-
-
Method Detail
-
addShutdownCallback
Cancellable addShutdownCallback(java.lang.Runnable callback)
Adds a Runnable shutdown callback to this class. Note: The returnedCancellablemust be retained on heap by caller to avoid premature garbage-collection of the registered callback (and to ensure the callback runs on shutdown).- Parameters:
callback- the shutdown callback to be executed upon shutdown.- Returns:
- a Cancellable wrapper of the provided callback or
nullif the shutdown hook is disabled and cannot be added. - Since:
- 2.1
-
-