Search in sources :

Example 1 with LoggerContext

use of org.apache.logging.log4j.spi.LoggerContext in project logging-log4j2 by apache.

the class LogManagerTest method testShutdown.

@Test
public void testShutdown() {
    final LoggerContext loggerContext = LogManager.getContext(false);
    LogManager.shutdown(loggerContext);
}
Also used : LoggerContext(org.apache.logging.log4j.spi.LoggerContext) Test(org.junit.Test)

Example 2 with LoggerContext

use of org.apache.logging.log4j.spi.LoggerContext in project mule by mulesoft.

the class MessageProcessingFlowTraceManager method initialise.

@Override
public void initialise() throws InitialisationException {
    LoggerContext context = LogManager.getContext(false);
    if (context != null && context instanceof LogConfigChangeSubject) {
        ((LogConfigChangeSubject) context).registerLogConfigChangeListener(logConfigChangeListener);
    }
    handleNotificationListeners();
}
Also used : LogConfigChangeSubject(org.mule.runtime.core.internal.logging.LogConfigChangeSubject) LoggerContext(org.apache.logging.log4j.spi.LoggerContext)

Example 3 with LoggerContext

use of org.apache.logging.log4j.spi.LoggerContext in project mule by mulesoft.

the class MessageProcessingFlowTraceManager method dispose.

@Override
public void dispose() {
    LoggerContext context = LogManager.getContext(false);
    if (context != null && context instanceof LogConfigChangeSubject) {
        ((LogConfigChangeSubject) context).unregisterLogConfigChangeListener(logConfigChangeListener);
    }
    removeNotificationListeners();
}
Also used : LogConfigChangeSubject(org.mule.runtime.core.internal.logging.LogConfigChangeSubject) LoggerContext(org.apache.logging.log4j.spi.LoggerContext)

Example 4 with LoggerContext

use of org.apache.logging.log4j.spi.LoggerContext in project logging-log4j2 by apache.

the class Category method getParent.

public final Category getParent() {
    if (!LogManager.isLog4jCorePresent()) {
        return null;
    }
    final org.apache.logging.log4j.Logger parent = CategoryUtil.getParent(logger);
    final LoggerContext loggerContext = CategoryUtil.getLoggerContext(logger);
    if (parent == null || loggerContext == null) {
        return null;
    }
    final ConcurrentMap<String, Logger> loggers = Hierarchy.getLoggersMap(loggerContext);
    final Logger parentLogger = loggers.get(parent.getName());
    return parentLogger == null ? new Category(parent) : parentLogger;
}
Also used : ExtendedLogger(org.apache.logging.log4j.spi.ExtendedLogger) LoggerContext(org.apache.logging.log4j.spi.LoggerContext)

Example 5 with LoggerContext

use of org.apache.logging.log4j.spi.LoggerContext in project logging-log4j2 by apache.

the class SimplePerfTest method workAroundLog4j2_5Bug.

private static void workAroundLog4j2_5Bug() {
    // use reflection so we can use the same test with older versions of log4j2
    try {
        final Method setUseThreadLocals = AsyncLoggerContext.class.getDeclaredMethod("setUseThreadLocals", new Class[] { boolean.class });
        final LoggerContext context = LogManager.getContext(false);
        setUseThreadLocals.invoke(context, new Object[] { Boolean.TRUE });
    } catch (final Throwable ignored) {
    }
}
Also used : Method(java.lang.reflect.Method) AsyncLoggerContext(org.apache.logging.log4j.core.async.AsyncLoggerContext) LoggerContext(org.apache.logging.log4j.spi.LoggerContext)

Aggregations

LoggerContext (org.apache.logging.log4j.spi.LoggerContext)15 Test (org.junit.Test)5 Log4j2Binder (com.navercorp.pinpoint.profiler.logging.Log4j2Binder)2 ExtendedLogger (org.apache.logging.log4j.spi.ExtendedLogger)2 LogConfigChangeSubject (org.mule.runtime.core.internal.logging.LogConfigChangeSubject)2 ILogger (com.hazelcast.logging.ILogger)1 Log4j2Factory (com.hazelcast.logging.Log4j2Factory)1 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)1 MockApplicationContextFactory (com.navercorp.pinpoint.test.MockApplicationContextFactory)1 TestClassLoader (com.navercorp.pinpoint.test.classloader.TestClassLoader)1 File (java.io.File)1 Method (java.lang.reflect.Method)1 Map (java.util.Map)1 ListAppender (org.apache.log4j.ListAppender)1 Logger (org.apache.log4j.Logger)1 AppenderAdapter (org.apache.log4j.bridge.AppenderAdapter)1 LoggingEvent (org.apache.log4j.spi.LoggingEvent)1 Logger (org.apache.logging.log4j.Logger)1 Appender (org.apache.logging.log4j.core.Appender)1 LifeCycle (org.apache.logging.log4j.core.LifeCycle)1