Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 671C2200C25 for ; Fri, 24 Feb 2017 20:21:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 65C2F160B69; Fri, 24 Feb 2017 19:21:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AD302160B62 for ; Fri, 24 Feb 2017 20:21:04 +0100 (CET) Received: (qmail 62184 invoked by uid 500); 24 Feb 2017 19:21:03 -0000 Mailing-List: contact dev-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 dev@accumulo.apache.org Received: (qmail 62164 invoked by uid 99); 24 Feb 2017 19:21:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2017 19:21:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5B656DFC1C; Fri, 24 Feb 2017 19:21:03 +0000 (UTC) From: mikewalch To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request #221: ACCUMULO-4588 Simplify Accumulo logging configur... Content-Type: text/plain Message-Id: <20170224192103.5B656DFC1C@git1-us-west.apache.org> Date: Fri, 24 Feb 2017 19:21:03 +0000 (UTC) archived-at: Fri, 24 Feb 2017 19:21:05 -0000 Github user mikewalch commented on a diff in the pull request: https://github.com/apache/accumulo/pull/221#discussion_r103013138 --- Diff: server/base/src/main/java/org/apache/accumulo/server/Accumulo.java --- @@ -108,69 +105,20 @@ public static synchronized Path getAccumuloInstanceIdPath(VolumeManager fs) { return ServerConstants.getInstanceIdLocation(v); } - /** - * Finds the best log4j configuration file. A generic file is used only if an application-specific file is not available. An XML file is preferred over a - * properties file, if possible. - * - * @param confDir - * directory where configuration files should reside - * @param application - * application name for configuration file name - * @return configuration file name - */ - static String locateLogConfig(String confDir, String application) { - String explicitConfigFile = System.getProperty("log4j.configuration"); - if (explicitConfigFile != null) { - return explicitConfigFile; - } - String[] configFiles = {String.format("%s/%s_logger.xml", confDir, application), String.format("%s/%s_logger.properties", confDir, application), - String.format("%s/examples/%s_logger.xml", confDir, application), String.format("%s/examples/%s_logger.properties", confDir, application), - String.format("%s/generic_logger.xml", confDir), String.format("%s/generic_logger.properties", confDir), - String.format("%s/examples/generic_logger.xml", confDir), String.format("%s/examples/generic_logger.properties", confDir),}; - String defaultConfigFile = String.format("%s/examples/generic_logger.xml", confDir); - for (String f : configFiles) { - if (new File(f).exists()) { - return f; - } - } - return defaultConfigFile; - } - - public static void setupLogging(String application) throws UnknownHostException { - System.setProperty("org.apache.accumulo.core.application", application); - - if (System.getenv("ACCUMULO_LOG_DIR") != null) { - System.setProperty("org.apache.accumulo.core.dir.log", System.getenv("ACCUMULO_LOG_DIR")); - } - - String localhost = InetAddress.getLocalHost().getHostName(); - System.setProperty("org.apache.accumulo.core.ip.localhost.hostname", localhost); - - // Use a specific log config, if it exists - String logConfigFile = locateLogConfig(System.getenv("ACCUMULO_CONF_DIR"), application); - // Turn off messages about not being able to reach the remote logger... we protect against that. - LogLog.setQuietMode(true); - - // Set up local file-based logging right away - Log4jConfiguration logConf = new Log4jConfiguration(logConfigFile); - logConf.resetLogger(); - } - public static void init(VolumeManager fs, ServerConfigurationFactory serverConfig, String application) throws IOException { final AccumuloConfiguration conf = serverConfig.getConfiguration(); final Instance instance = serverConfig.getInstance(); - // Use a specific log config, if it exists - final String logConfigFile = locateLogConfig(System.getenv("ACCUMULO_CONF_DIR"), application); - - // Set up polling log4j updates and log-forwarding using information advertised in zookeeper by the monitor - MonitorLog4jWatcher logConfigWatcher = new MonitorLog4jWatcher(instance.getInstanceID(), logConfigFile); - logConfigWatcher.setDelay(5000L); - logConfigWatcher.start(); - - // Makes sure the log-forwarding to the monitor is configured - int[] logPort = conf.getPort(Property.MONITOR_LOG4J_PORT); - System.setProperty("org.apache.accumulo.core.host.log.port", Integer.toString(logPort[0])); + String logConfigFile = System.getProperty("log4j.configuration"); + if (logConfigFile != null) { + if (logConfigFile.startsWith("file:")) { --- End diff -- I don't know of a class that will do it for you. I googled it and couldn't find one. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---