This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.7 by this push:
new ebcc8cade [KYUUBI #5129] KyuubiBeeline should redirect JDK logging
ebcc8cade is described below
commit ebcc8cadeae6da389e16f3aee09c3c832b54cc5d
Author: Cheng Pan <[email protected]>
AuthorDate: Thu Aug 3 19:27:31 2023 +0800
[KYUUBI #5129] KyuubiBeeline should redirect JDK logging
### _Why are the changes needed?_
Otherwise we can not see JDK logs like Krb5.
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including
negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [x] [Run
test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests)
locally before make a pull request
Closes #5129 from pan3793/beeline-log.
Closes #5129
100094823 [Cheng Pan] KyuubiBeeline should redirect JDK logging
Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit f41a8e5b3dc4b443c988a0867e4b315e8767c0e5)
Signed-off-by: Cheng Pan <[email protected]>
---
kyuubi-hive-beeline/pom.xml | 5 +++++
.../main/java/org/apache/hive/beeline/KyuubiBeeLine.java | 16 ++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/kyuubi-hive-beeline/pom.xml b/kyuubi-hive-beeline/pom.xml
index d37a5bd11..55204647b 100644
--- a/kyuubi-hive-beeline/pom.xml
+++ b/kyuubi-hive-beeline/pom.xml
@@ -155,6 +155,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
diff --git
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java
index c137d0bd2..4966f1cd3 100644
---
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java
+++
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java
@@ -29,6 +29,22 @@ import org.apache.commons.cli.ParseException;
import org.apache.hive.common.util.HiveStringUtils;
public class KyuubiBeeLine extends BeeLine {
+
+ static {
+ try {
+ // We use reflection here to handle the case where users remove the
+ // slf4j-to-jul bridge order to route their logs to JUL.
+ Class<?> bridgeClass =
Class.forName("org.slf4j.bridge.SLF4JBridgeHandler");
+ bridgeClass.getMethod("removeHandlersForRootLogger").invoke(null);
+ boolean installed = (boolean)
bridgeClass.getMethod("isInstalled").invoke(null);
+ if (!installed) {
+ bridgeClass.getMethod("install").invoke(null);
+ }
+ } catch (ReflectiveOperationException cnf) {
+ // can't log anything yet so just fail silently
+ }
+ }
+
public static final String KYUUBI_BEELINE_DEFAULT_JDBC_DRIVER =
"org.apache.kyuubi.jdbc.KyuubiHiveDriver";
protected KyuubiCommands commands = new KyuubiCommands(this);