You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2017/11/10 01:38:33 UTC

hive git commit: HIVE-16075 : MetaStore needs to reinitialize log4j to allow log specific settings via hiveconf take effect (Yunfei Liu via Prashanth J)

Repository: hive
Updated Branches:
  refs/heads/master c2be4b717 -> 9f653d2c9


HIVE-16075 : MetaStore needs to reinitialize log4j to allow log specific settings via hiveconf take effect (Yunfei Liu via Prashanth J)

Signed-off-by: Ashutosh Chauhan <ha...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/9f653d2c
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/9f653d2c
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/9f653d2c

Branch: refs/heads/master
Commit: 9f653d2c993802d8d05765f8b28fc63e8945f6ad
Parents: c2be4b7
Author: yunfei liu <li...@cmss.chinamobile.com>
Authored: Wed Mar 1 01:47:00 2017 -0800
Committer: Ashutosh Chauhan <ha...@apache.org>
Committed: Thu Nov 9 17:38:23 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hive/metastore/HiveMetaStore.java    | 23 +++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/9f653d2c/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index a54a82b..ed0f4d8 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -150,6 +150,8 @@ import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hive.common.util.HiveStringUtils;
 import org.apache.hive.common.util.ShutdownHookManager;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.thrift.TException;
 import org.apache.thrift.TProcessor;
 import org.apache.thrift.protocol.TBinaryProtocol;
@@ -7698,17 +7700,22 @@ public class HiveMetaStore extends ThriftHiveMetastore {
     // any log specific settings via hiveconf will be ignored
     Properties hiveconf = cli.addHiveconfToSystemProperties();
 
-    // If the log4j.configuration property hasn't already been explicitly set,
-    // use Hive's default log4j configuration
-    if (System.getProperty("log4j.configurationFile") == null) {
-      // NOTE: It is critical to do this here so that log4j is reinitialized
-      // before any of the other core hive classes are loaded
-      try {
+    // NOTE: It is critical to do this here so that log4j is reinitialized
+    // before any of the other core hive classes are loaded
+    try {
+      // If the log4j.configuration property hasn't already been explicitly set,
+      // use Hive's default log4j configuration
+      if (System.getProperty("log4j.configurationFile") == null) {
         LogUtils.initHiveLog4j();
-      } catch (LogInitializationException e) {
-        HMSHandler.LOG.warn(e.getMessage());
+      }else{
+        //reconfigure log4j after settings via hiveconf are write into System Properties
+        LoggerContext context =  (LoggerContext)LogManager.getContext(false);
+        context.reconfigure();
       }
+    } catch (LogInitializationException e) {
+      HMSHandler.LOG.warn(e.getMessage());
     }
+     
     HiveStringUtils.startupShutdownMessage(HiveMetaStore.class, args, LOG);
 
     try {