diff --git a/cli/src/java/org/apache/hadoop/hive/cli/OptionsProcessor.java b/cli/src/java/org/apache/hadoop/hive/cli/OptionsProcessor.java index b6a76d2..b6ab345 100644 --- a/cli/src/java/org/apache/hadoop/hive/cli/OptionsProcessor.java +++ b/cli/src/java/org/apache/hadoop/hive/cli/OptionsProcessor.java @@ -29,7 +29,7 @@ import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; -import org.apache.logging.log4j.Level; +import org.apache.hadoop.hive.common.cli.CommonCliOptions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -122,19 +122,7 @@ public boolean process_stage1(String[] argv) { // if we still see it, split logger and level separately for hive.root.logger // and hive.log.level respectively if (propKey.equalsIgnoreCase("hive.root.logger")) { - String propVal = confProps.getProperty(propKey); - if (propVal.contains(",")) { - String[] tokens = propVal.split(","); - for (String token : tokens) { - if (Level.getLevel(token) == null) { - System.setProperty("hive.root.logger", token); - } else { - System.setProperty("hive.log.level", token); - } - } - } else { - System.setProperty(propKey, confProps.getProperty(propKey)); - } + CommonCliOptions.splitAndSetLogger(propKey, confProps); } else { System.setProperty(propKey, confProps.getProperty(propKey)); } diff --git a/common/src/java/org/apache/hadoop/hive/common/cli/CommonCliOptions.java b/common/src/java/org/apache/hadoop/hive/common/cli/CommonCliOptions.java index e229580..5a991ec 100644 --- a/common/src/java/org/apache/hadoop/hive/common/cli/CommonCliOptions.java +++ b/common/src/java/org/apache/hadoop/hive/common/cli/CommonCliOptions.java @@ -26,6 +26,7 @@ import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.logging.log4j.Level; /** * Reusable code for Hive Cli's. @@ -94,11 +95,31 @@ public Properties addHiveconfToSystemProperties() { System.err.println( "hiveconf: " + propKey + "=" + confProps.getProperty(propKey)); } - System.setProperty(propKey, confProps.getProperty(propKey)); + if (propKey.equalsIgnoreCase("hive.root.logger")) { + splitAndSetLogger(propKey, confProps); + } else { + System.setProperty(propKey, confProps.getProperty(propKey)); + } } return confProps; } + public static void splitAndSetLogger(final String propKey, final Properties confProps) { + String propVal = confProps.getProperty(propKey); + if (propVal.contains(",")) { + String[] tokens = propVal.split(","); + for (String token : tokens) { + if (Level.getLevel(token) == null) { + System.setProperty("hive.root.logger", token); + } else { + System.setProperty("hive.log.level", token); + } + } + } else { + System.setProperty(propKey, confProps.getProperty(propKey)); + } + } + /** * Print usage information for the CLI. */ diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java b/service/src/java/org/apache/hive/service/server/HiveServer2.java index c601614..892a476 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -46,6 +46,7 @@ import org.apache.hadoop.hive.common.LogUtils; import org.apache.hadoop.hive.common.LogUtils.LogInitializationException; import org.apache.hadoop.hive.common.ServerUtils; +import org.apache.hadoop.hive.common.cli.CommonCliOptions; import org.apache.hadoop.hive.common.metrics.common.MetricsFactory; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; @@ -694,7 +695,11 @@ ServerOptionsProcessorResponse parse(String[] argv) { for (String propKey : confProps.stringPropertyNames()) { // save logging message for log4j output latter after log4j initialize properly debugMessage.append("Setting " + propKey + "=" + confProps.getProperty(propKey) + ";\n"); - System.setProperty(propKey, confProps.getProperty(propKey)); + if (propKey.equalsIgnoreCase("hive.root.logger")) { + CommonCliOptions.splitAndSetLogger(propKey, confProps); + } else { + System.setProperty(propKey, confProps.getProperty(propKey)); + } } // Process --help