org.apache.logging.log4j.core.util.ShutdownCallbackRegistry Java Examples

The following examples show how to use org.apache.logging.log4j.core.util.ShutdownCallbackRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Log4jContextFactory.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #2
Source File: Log4jContextFactory.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private static ShutdownCallbackRegistry createShutdownCallbackRegistry() {
    try {
        final ShutdownCallbackRegistry registry = Loader.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();
}
 
Example #3
Source File: Log4J2LoggerFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Log4J2LoggerFactory() {
  // map message factory to simple, since default message factory is reusable - and will remap our object to string message, without access to object variant
  System.setProperty("log4j2.messageFactory", "org.apache.logging.log4j.message.SimpleMessageFactory");
  System.setProperty(ShutdownCallbackRegistry.SHUTDOWN_HOOK_ENABLED, "false");
  myLoggerContext = init();
}
 
Example #4
Source File: Log4jContextFactory.java    From logging-log4j2 with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: Log4jContextFactory.java    From logging-log4j2 with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the ShutdownCallbackRegistry
 *
 * @return the ShutdownCallbackRegistry
 * @since 2.4
 */
public ShutdownCallbackRegistry getShutdownCallbackRegistry() {
	return shutdownCallbackRegistry;
}