@Test public void testShutdownCallbackRegistry() throws Exception { final LoggerContext context = ctx.getLoggerContext(); assertTrue("LoggerContext should be started", context.isStarted()); assertThat(Registry.CALLBACKS, hasSize(1)); Registry.shutdown(); assertTrue("LoggerContext should be stopped", context.isStopped()); assertThat(Registry.CALLBACKS, hasSize(0)); final ContextSelector selector = ((Log4jContextFactory) LogManager.getFactory()).getSelector(); assertThat(selector.getLoggerContexts(), not(hasItem(context))); }
private void stop(LoggerContext loggerContext) { if (loggerContext != null && !loggerContext.isStopping() && !loggerContext.isStopped()) { loggerContext.stop(); } }
private void stop(LoggerContext loggerContext) { if (loggerContext != null && !loggerContext.isStopping() && !loggerContext.isStopped()) { loggerContext.stop(); } }
private void stop(LoggerContext loggerContext) { if (loggerContext != null && !loggerContext.isStopping() && !loggerContext.isStopped()) { loggerContext.stop(); } }
/** * Starts with a specific configuration. * * @param config The new Configuration. */ public void start(final Configuration config) { LOGGER.debug("Starting LoggerContext[name={}, {}] with configuration {}...", getName(), this, config); if (configLock.tryLock()) { try { if (this.isInitialized() || this.isStopped()) { if (this.configuration.isShutdownHookEnabled()) { setUpShutdownHook(); } this.setStarted(); } } finally { configLock.unlock(); } } setConfiguration(config); LOGGER.debug("LoggerContext[name={}, {}] started OK with configuration {}.", getName(), this, config); }
@Override public void start() { LOGGER.debug("Starting LoggerContext[name={}, {}]...", getName(), this); if (PropertiesUtil.getProperties().getBooleanProperty("log4j.LoggerContext.stacktrace.on.start", false)) { LOGGER.debug("Stack trace to locate invoker", new Exception("Not a real error, showing stack trace to locate invoker")); } if (configLock.tryLock()) { try { if (this.isInitialized() || this.isStopped()) { this.setStarting(); reconfigure(); if (this.configuration.isShutdownHookEnabled()) { setUpShutdownHook(); } this.setStarted(); } } finally { configLock.unlock(); } } LOGGER.debug("LoggerContext[name={}, {}] started OK.", getName(), this); }
configLock.lock(); try { if (this.isStopped()) { return true;