Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 99E6A17CBC for ; Mon, 27 Oct 2014 19:13:06 +0000 (UTC) Received: (qmail 94886 invoked by uid 500); 27 Oct 2014 19:13:00 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 94850 invoked by uid 500); 27 Oct 2014 19:13:00 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 94764 invoked by uid 99); 27 Oct 2014 19:13:00 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Oct 2014 19:13:00 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E8D9990AD3A; Mon, 27 Oct 2014 19:12:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Mon, 27 Oct 2014 19:12:59 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] git commit: ACCUMULO-3264 Only reset logging configuration when we're certain that we have configuration files Repository: accumulo Updated Branches: refs/heads/1.6 8b93f5d18 -> e4dbe897c refs/heads/master b97527181 -> 014d9d955 ACCUMULO-3264 Only reset logging configuration when we're certain that we have configuration files The original change broke logging for all of the ITs because the logging configuration was reset without having any means to add back the original log4j configuration from maven. This shouldn't have been a problem because MAC should really be setting up logging in the same way that a real cluster does instead of faking it. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/e4dbe897 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e4dbe897 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e4dbe897 Branch: refs/heads/1.6 Commit: e4dbe897cfbd710549a0368e156a49181409a671 Parents: 8b93f5d Author: Josh Elser Authored: Mon Oct 27 14:57:10 2014 -0400 Committer: Josh Elser Committed: Mon Oct 27 14:57:10 2014 -0400 ---------------------------------------------------------------------- .../org/apache/accumulo/server/Accumulo.java | 5 +++-- .../server/watcher/Log4jConfiguration.java | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4dbe897/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java index 0dc76b2..1e7658a 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java +++ b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java @@ -161,11 +161,12 @@ public class Accumulo { // Read the auditing config String auditConfig = String.format("%s/auditLog.xml", System.getenv("ACCUMULO_CONF_DIR")); - DOMConfigurator.configureAndWatch(auditConfig, 5000); - // Set up local file-based logging right away Log4jConfiguration logConf = new Log4jConfiguration(logConfigFile); logConf.resetLogger(); + + // Watch the auditLog.xml for the future updates + DOMConfigurator.configureAndWatch(auditConfig, 5000); } public static void init(VolumeManager fs, ServerConfiguration serverConfig, String application) throws IOException { http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4dbe897/server/base/src/main/java/org/apache/accumulo/server/watcher/Log4jConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/watcher/Log4jConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/watcher/Log4jConfiguration.java index 7dea7a3..0cac730 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/watcher/Log4jConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/watcher/Log4jConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.accumulo.server.watcher; +import java.io.File; + import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.xml.DOMConfigurator; @@ -27,10 +29,12 @@ public class Log4jConfiguration { private final boolean usingProperties; private final String filename; + private final File log4jFile; public Log4jConfiguration(String filename) { usingProperties = (filename != null && filename.endsWith(".properties")); this.filename = filename; + log4jFile = new File(filename); } public boolean isUsingProperties() { @@ -38,12 +42,15 @@ public class Log4jConfiguration { } public void resetLogger() { - // Force a reset on the logger's configuration - LogManager.resetConfiguration(); - if (usingProperties) { - new PropertyConfigurator().doConfigure(filename, LogManager.getLoggerRepository()); - } else { - new DOMConfigurator().doConfigure(filename, LogManager.getLoggerRepository()); + // Force a reset on the logger's configuration, but only if the configured log4j file actually exists + // If we reset the configuration blindly, the ITs will not get any logging as they don't set it up on their own + if (log4jFile.exists() && log4jFile.isFile() && log4jFile.canRead()) { + LogManager.resetConfiguration(); + if (usingProperties) { + new PropertyConfigurator().doConfigure(filename, LogManager.getLoggerRepository()); + } else { + new DOMConfigurator().doConfigure(filename, LogManager.getLoggerRepository()); + } } } }