/** * Constructs a Log4jContextFactory using the provided ContextSelector and ShutdownRegistrationStrategy. * * @param selector the selector to use * @param shutdownCallbackRegistry the ShutdownRegistrationStrategy to use * @since 2.1 */ public Log4jContextFactory(final ContextSelector selector, final ShutdownCallbackRegistry shutdownCallbackRegistry) { this.selector = Objects.requireNonNull(selector, "No ContextSelector provided"); this.shutdownCallbackRegistry = Objects.requireNonNull(shutdownCallbackRegistry, "No ShutdownCallbackRegistry provided"); LOGGER.debug("Using ShutdownCallbackRegistry {}", shutdownCallbackRegistry.getClass()); initializeShutdownCallbackRegistry(); }
private static ShutdownCallbackRegistry createShutdownCallbackRegistry() { try { final ShutdownCallbackRegistry registry = LoaderUtil.newCheckedInstanceOfProperty( ShutdownCallbackRegistry.SHUTDOWN_CALLBACK_REGISTRY, ShutdownCallbackRegistry.class ); if (registry != null) { return registry; } } catch (final Exception e) { LOGGER.error("Unable to create custom ShutdownCallbackRegistry. Falling back to default.", e); } return new DefaultShutdownCallbackRegistry(); }
/** * Constructs a Log4jContextFactory using the ContextSelector from {@link Constants#LOG4J_CONTEXT_SELECTOR} * and the provided ShutdownRegistrationStrategy. * * @param shutdownCallbackRegistry the ShutdownRegistrationStrategy to use * @since 2.1 */ public Log4jContextFactory(final ShutdownCallbackRegistry shutdownCallbackRegistry) { this(createContextSelector(), shutdownCallbackRegistry); }
/** * Returns the ShutdownCallbackRegistry * * @return the ShutdownCallbackRegistry * @since 2.4 */ public ShutdownCallbackRegistry getShutdownCallbackRegistry() { return shutdownCallbackRegistry; }