@Override protected void after() { LogManager.setFactory(this.restoreLoggerContextFactory); }
private static boolean checkAndSetAsyncLogging(final Configuration conf) { final boolean asyncLogging = MetastoreConf.getBoolVar(conf, ConfVars.ASYNC_LOG_ENABLED); if (asyncLogging) { System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); // default is ClassLoaderContextSelector which is created during automatic logging // initialization in a static initialization block. // Changing ContextSelector at runtime requires creating new context factory which will // internally create new context selector based on system property. LogManager.setFactory(new Log4jContextFactory()); } return asyncLogging; }
public static boolean checkAndSetAsyncLogging(final Configuration conf) { final boolean asyncLogging = HiveConf.getBoolVar(conf, ConfVars.HIVE_ASYNC_LOG_ENABLED); if (asyncLogging) { System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); // default is ClassLoaderContextSelector which is created during automatic logging // initialization in a static initialization block. // Changing ContextSelector at runtime requires creating new context factory which will // internally create new context selector based on system property. LogManager.setFactory(new Log4jContextFactory()); } return asyncLogging; }
@Override protected void before() throws Throwable { this.restoreLoggerContextFactory = LogManager.getFactory(); LogManager.setFactory(this.loggerContextFactory); }
@Test public void disposesLogContextFactory() throws Exception { final LoggerContextFactory originalFactory = LogManager.getFactory(); try { MuleLog4jContextFactory contextFactory = mock(MuleLog4jContextFactory.class); LogManager.setFactory(contextFactory); container.stop(); verify(contextFactory).dispose(); } finally { LogManager.setFactory(originalFactory); } }
private static boolean checkAndSetAsyncLogging(final Configuration conf) { final boolean asyncLogging = MetastoreConf.getBoolVar(conf, ConfVars.ASYNC_LOG_ENABLED); if (asyncLogging) { System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); // default is ClassLoaderContextSelector which is created during automatic logging // initialization in a static initialization block. // Changing ContextSelector at runtime requires creating new context factory which will // internally create new context selector based on system property. LogManager.setFactory(new Log4jContextFactory()); } return asyncLogging; }
public static boolean checkAndSetAsyncLogging(final Configuration conf) { final boolean asyncLogging = HiveConf.getBoolVar(conf, ConfVars.HIVE_ASYNC_LOG_ENABLED); if (asyncLogging) { System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); // default is ClassLoaderContextSelector which is created during automatic logging // initialization in a static initialization block. // Changing ContextSelector at runtime requires creating new context factory which will // internally create new context selector based on system property. LogManager.setFactory(new Log4jContextFactory()); } return asyncLogging; }
LogManager.setFactory(_originalFactory); } finally { try {
public void init(@Nonnull Log4J2BasedLoggingEnvironmentConfiguration with) { synchronized (this) { if (_factory == null) { _originalFactory = findOriginalFactory(); _factory = new LoggerContextFactoryImpl(createLoggerContext(with)); _loggerFactory = new LoggerFactory(_factory); LogManager.setFactory(_factory); _loggerFactoryRegistration = LoggerFactoryRegistry.register(_loggerFactory); if (with.isInstallSl4jRequired()) { _installation = Slf4jUtils.tryInstallSlf4jBridges(_loggerFactory); } } } }