Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 60F22112E6 for ; Mon, 22 Sep 2014 10:06:34 +0000 (UTC) Received: (qmail 87012 invoked by uid 500); 22 Sep 2014 10:06:34 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 86958 invoked by uid 500); 22 Sep 2014 10:06:34 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 86948 invoked by uid 99); 22 Sep 2014 10:06:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2014 10:06:34 +0000 Date: Mon, 22 Sep 2014 10:06:34 +0000 (UTC) From: "Remko Popma (JIRA)" To: log4j-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LOG4J2-807) Disruptor is null when configuration is reloaded (asyncRoot + monitorInterval) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4J2-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14143065#comment-14143065 ] Remko Popma commented on LOG4J2-807: ------------------------------------ The problem is caused by a bug in AbstractConfiguration: During reconfiguration, a new configuration is started with new appenders and loggers. This increases the AsyncLoggerConfigHelper ref count to 2. (So far so good.) After that, the old configuration is stopped. This logic has a bug, resulting in the root async logger being stopped twice. This brings down the ref count to zero and the Disruptor is shut down. Subsequent logging will fail. Apart from fixing this bug, I'll also improve the trace logging for async loggers a little so that it is easier to see what is going on. The current log does not show that it is the same logger that is stopped twice, because the root logger name is the empty string. I'll output "root" instead in the trace logs to aid future debugging. Current: {code} 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfig[] stopping... 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfigHelper: not shutting down disruptor: ref count is 1. 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfig[] stopping... 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfigHelper: shutting down disruptor: ref count is 0. {code} After: {code} 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfig[root] stopping... 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfigHelper: not shutting down disruptor: ref count is 1. 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfig[root] stopping... 2014-09-22 19:01:50,617 TRACE AsyncLoggerConfigHelper: shutting down disruptor: ref count is 0. {code} > Disruptor is null when configuration is reloaded (asyncRoot + monitorInterval) > ------------------------------------------------------------------------------ > > Key: LOG4J2-807 > URL: https://issues.apache.org/jira/browse/LOG4J2-807 > Project: Log4j 2 > Issue Type: Bug > Affects Versions: 2.0.2 > Reporter: Florin Marinoiu > Assignee: Remko Popma > Fix For: 2.1 > > Attachments: async-root-reload - trace.log, async-root-reload-test.zip, async-root-reload.log > > > We have a XML configuration with and monitorInterval. When the configuration file is reloaded I have a NPE and log4j become unavailable: > {code} > 2014-08-29 10:39:59,079 ERROR Could not register mbeans java.lang.NullPointerException > at org.apache.logging.log4j.core.async.AsyncLoggerConfigHelper.createRingBufferAdmin(AsyncLoggerConfigHelper.java:360) > at org.apache.logging.log4j.core.async.AsyncLoggerConfig.createRingBufferAdmin(AsyncLoggerConfig.java:148) > {code} > Here is my config: > {code} > > > > > > %d %-5p [%c{1.}] %m%n > > > > > > > > > > {code} > And a code snippet to reproduce: > {code} > public class Log4jAsyncRootReloadTest { > public static void main(String[] args) throws InterruptedException { > final File config = new File("./log4j2.xml"); > System.setProperty("log4j.configurationFile", "file://" + config.getAbsolutePath().replaceAll("\\\\", "/")); > Logger logger = LogManager.getLogger(Log4jAsyncRootReloadTest.class); > logger.info("Log4j configured, will be reconfigured in aprox. 5 sec"); > config.setLastModified(System.currentTimeMillis()); > for (int i = 0; i < 10; i++) { > Thread.sleep(1000); > logger.info("Log4j waiting for reconfiguration"); > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org