From 0dda95a5f888e7d680c83c7ea62ac08156e6694f Mon Sep 17 00:00:00 2001 From: Istvan Toth Date: Tue, 14 Jan 2025 16:52:43 +0100 Subject: [PATCH] PHOENIX-7477 Set java.util.logging.config.class in scripts (#2040) and add org.slf4:jul-to-slf4j to classpath where needed --- bin/performance.py | 4 +++- bin/pherf-standalone.py | 3 ++- bin/phoenix_utils.py | 2 ++ bin/psql.py | 4 +++- bin/sqlline.py | 3 ++- .../src/build/components/all-common-dependencies.xml | 1 + phoenix-core-client/pom.xml | 4 ++++ phoenix-core/pom.xml | 8 ++++++++ phoenix-pherf/pom.xml | 8 ++++++++ pom.xml | 5 +++++ 10 files changed, 38 insertions(+), 4 deletions(-) diff --git a/bin/performance.py b/bin/performance.py index 5b09a29c93f..11d8b483ee1 100755 --- a/bin/performance.py +++ b/bin/performance.py @@ -65,7 +65,9 @@ def createFileWithContent(filename, content): java_cmd = phoenix_utils.java -execute = ('%s %s $PHOENIX_OPTS -cp "%s%s%s%s%s"-Dlog4j2.configurationFile=file:' + +execute = ('%s %s $PHOENIX_OPTS -cp "%s%s%s%s%s"' + + ' -Djava.util.logging.config.class=org.apache.hadoop.hbase.logging.JulToSlf4jInitializer ' + + ' -Dlog4j2.configurationFile=file:' + os.path.join(phoenix_utils.current_dir, "log4j2.properties") + ' org.apache.phoenix.util.PhoenixRuntime -t %s %s ') % \ (java_cmd, phoenix_utils.jvm_module_flags, hbase_config_path, os.pathsep, diff --git a/bin/pherf-standalone.py b/bin/pherf-standalone.py index 14f5500fb15..e53ecf9d34e 100755 --- a/bin/pherf-standalone.py +++ b/bin/pherf-standalone.py @@ -38,7 +38,8 @@ phoenix_utils.logging_jar + os.pathsep + \ phoenix_utils.phoenix_client_embedded_jar + os.pathsep +\ phoenix_utils.phoenix_pherf_jar + \ - '" -Dlog4j2.configurationFile=file:' + \ + '" -Djava.util.logging.config.class=org.apache.hadoop.hbase.logging.JulToSlf4jInitializer ' +\ + ' -Dlog4j2.configurationFile=file:' + \ os.path.join(phoenix_utils.current_dir, "log4j2.properties") + \ " org.apache.phoenix.pherf.Pherf " + args diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py index 48e7a42d5ab..43f666f7f24 100755 --- a/bin/phoenix_utils.py +++ b/bin/phoenix_utils.py @@ -87,6 +87,7 @@ def setPath(): LOGGING_JAR_PATTERN = "log4j-core*.jar" LOGGING_JAR_PATTERN2 = "log4j-api*.jar" LOGGING_JAR_PATTERN3 = "log4j-1.2-api*.jar" + LOGGING_JAR_PATTERN4 = "jul-to-slf4j*.jar" SQLLINE_WITH_DEPS_PATTERN = "sqlline-*-jar-with-dependencies.jar" @@ -200,6 +201,7 @@ def setPath(): logging_jar = findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN, os.path.join(current_dir, "..","lib")) logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN2, os.path.join(current_dir, "..","lib")) logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN3, os.path.join(current_dir, "..","lib")) + logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN4, os.path.join(current_dir, "..","lib")) __set_java_home() __set_jvm_flags() diff --git a/bin/psql.py b/bin/psql.py index 03d76bc8309..decf8c22584 100755 --- a/bin/psql.py +++ b/bin/psql.py @@ -34,7 +34,9 @@ ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + phoenix_utils.hadoop_conf + \ os.pathsep + phoenix_utils.slf4j_backend_jar + \ os.pathsep + phoenix_utils.logging_jar + \ - os.pathsep + phoenix_utils.phoenix_client_embedded_jar + '" -Dlog4j2.configurationFile=file:' + \ + os.pathsep + phoenix_utils.phoenix_client_embedded_jar + \ + '" -Djava.util.logging.config.class=org.apache.hadoop.hbase.logging.JulToSlf4jInitializer ' + \ + ' -Dlog4j2.configurationFile=file:' + \ os.path.join(phoenix_utils.current_dir, "log4j2.properties") + \ " org.apache.phoenix.util.PhoenixRuntime " + args diff --git a/bin/sqlline.py b/bin/sqlline.py index b927c94df4d..98ade9137bf 100755 --- a/bin/sqlline.py +++ b/bin/sqlline.py @@ -97,7 +97,8 @@ def kill_child(): phoenix_utils.slf4j_backend_jar + os.pathsep + \ phoenix_utils.logging_jar + os.pathsep + \ phoenix_utils.phoenix_client_lite_jar + \ - '" -Dlog4j2.configurationFile=file:' + os.path.join(phoenix_utils.current_dir, "log4j2.properties") + \ + '" -Djava.util.logging.config.class=org.apache.hadoop.hbase.logging.JulToSlf4jInitializer ' + \ + ' -Dlog4j2.configurationFile=file:' + os.path.join(phoenix_utils.current_dir, "log4j2.properties") + \ disable_jna + \ " sqlline.SqlLine -d org.apache.phoenix.jdbc.PhoenixDriver" + \ (not args.noconnect and " -u " + phoenix_utils.shell_quote([jdbc_url]) or "") + \ diff --git a/phoenix-assembly/src/build/components/all-common-dependencies.xml b/phoenix-assembly/src/build/components/all-common-dependencies.xml index 4a5fd9bf865..68290829e75 100644 --- a/phoenix-assembly/src/build/components/all-common-dependencies.xml +++ b/phoenix-assembly/src/build/components/all-common-dependencies.xml @@ -24,6 +24,7 @@ /lib sqlline:sqlline:jar:jar-with-dependencies + org.slf4j:jul-to-slf4j org.apache.logging.log4j:log4j-slf4j-impl org.apache.logging.log4j:log4j-api org.apache.logging.log4j:log4j-core diff --git a/phoenix-core-client/pom.xml b/phoenix-core-client/pom.xml index c9112e850ba..6bafd9db2f7 100644 --- a/phoenix-core-client/pom.xml +++ b/phoenix-core-client/pom.xml @@ -151,6 +151,10 @@ + + org.slf4j + jul-to-slf4j + org.apache.logging.log4j log4j-api diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml index eb02d88f07d..691731627d8 100644 --- a/phoenix-core/pom.xml +++ b/phoenix-core/pom.xml @@ -105,6 +105,9 @@ org.apache.logging.log4j:log4j-1.2-api + + org.slf4j:jul-to-slf4j + @@ -462,6 +465,11 @@ + + org.slf4j + jul-to-slf4j + test + org.apache.logging.log4j log4j-api diff --git a/phoenix-pherf/pom.xml b/phoenix-pherf/pom.xml index 7c3e56982f8..46e1847f47b 100644 --- a/phoenix-pherf/pom.xml +++ b/phoenix-pherf/pom.xml @@ -161,6 +161,11 @@ + + org.slf4j + jul-to-slf4j + test + org.apache.logging.log4j log4j-api @@ -311,6 +316,9 @@ org.apache.logging.log4j:log4j-1.2-api + + org.slf4j:jul-to-slf4j + diff --git a/pom.xml b/pom.xml index 2448da2576b..7ffc8189767 100644 --- a/pom.xml +++ b/pom.xml @@ -1799,6 +1799,11 @@ slf4j-reload4j ${slf4j.version} + + org.slf4j + jul-to-slf4j + ${slf4j.version} + org.apache.logging.log4j log4j-api