You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by je...@apache.org on 2021/06/28 15:30:29 UTC

[tez] branch branch-0.9 updated: TEZ-3918. Setting tez.task.log.level does not work

This is an automated email from the ASF dual-hosted git repository.

jeagles pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/tez.git


The following commit(s) were added to refs/heads/branch-0.9 by this push:
     new f3440ab  TEZ-3918. Setting tez.task.log.level does not work
f3440ab is described below

commit f3440abb68beed7d52ad57715c8b1bdd7c42af8f
Author: Kuhu Shukla <ks...@apache.org>
AuthorDate: Mon Jun 28 10:15:42 2021 -0500

    TEZ-3918. Setting tez.task.log.level does not work
    
    Signed-off-by: Jonathan Eagles <je...@apache.org>
    (cherry picked from commit 26b86e7646021c3bdf1e54a7ee225f46397eba42)
---
 .../java/org/apache/tez/client/TezClientUtils.java | 22 +++++++++++++---------
 .../org/apache/tez/client/TestTezClientUtils.java  | 10 ++++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java b/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java
index 26d82b7..618a024 100644
--- a/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java
+++ b/tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java
@@ -750,13 +750,6 @@ public class TezClientUtils {
   
   static void maybeAddDefaultLoggingJavaOpts(String logLevel, List<String> vargs) {
     Objects.requireNonNull(vargs);
-    if (!vargs.isEmpty()) {
-      for (String arg : vargs) {
-        if (arg.contains(TezConstants.TEZ_ROOT_LOGGER_NAME)) {
-          return;
-        }
-      }
-    }
     TezClientUtils.addLog4jSystemProperties(logLevel, vargs);
   }
 
@@ -819,8 +812,19 @@ public class TezClientUtils {
         + TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE);
     vargs.add("-D" + YarnConfiguration.YARN_APP_CONTAINER_LOG_DIR + "="
         + ApplicationConstants.LOG_DIR_EXPANSION_VAR);
-    vargs.add("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=" + logLevel
-        + "," + TezConstants.TEZ_CONTAINER_LOGGER_NAME);
+    boolean isRootLoggerPresent = false;
+    String rootLoggerArg = "-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=" + logLevel
+        + "," + TezConstants.TEZ_CONTAINER_LOGGER_NAME;
+    for (int i = 0; i < vargs.size(); i++) {
+      String arg = vargs.get(i);
+      if (arg.contains(TezConstants.TEZ_ROOT_LOGGER_NAME)) {
+        vargs.set(i, rootLoggerArg);
+        isRootLoggerPresent = true;
+      }
+    }
+    if (!isRootLoggerPresent) {
+      vargs.add(rootLoggerArg);
+    }
   }
 
   static ConfigurationProto createFinalConfProtoForApp(Configuration amConf,
diff --git a/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java b/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java
index c70386b..36a2d51 100644
--- a/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java
+++ b/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java
@@ -680,6 +680,16 @@ public class TestTezClientUtils {
         javaOpts.contains("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator"));
   }
 
+  @Test
+  public void testDefaultLoggingJavaOptsWithRootLogger() {
+    String origJavaOpts = "-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=INFO";
+    String javaOpts = TezClientUtils.maybeAddDefaultLoggingJavaOpts("FOOBAR", origJavaOpts);
+    Assert.assertNotNull(javaOpts);
+    Assert.assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR"));
+    Assert.assertTrue(javaOpts.contains(TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE)
+        && javaOpts.contains("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator"));
+  }
+
   @Test (timeout = 5000)
   public void testConfSerializationForAm() {
     Configuration conf =new Configuration(false);