2023-03-21 08:40:58 +00:00
|
|
|
From a59ddba0d41b0ba1ea9c8c6ac541a71d737cdf30 Mon Sep 17 00:00:00 2001
|
2017-06-08 10:46:42 +00:00
|
|
|
From: Michael Simacek <msimacek@redhat.com>
|
|
|
|
Date: Tue, 6 Jun 2017 13:47:43 +0200
|
2023-03-21 08:40:58 +00:00
|
|
|
Subject: [PATCH 2/3] Invoke logback via reflection
|
2017-06-08 10:46:42 +00:00
|
|
|
|
|
|
|
---
|
2023-03-21 08:40:58 +00:00
|
|
|
.../cli/logging/impl/LogbackConfiguration.java | 18 +++++++++++++-----
|
|
|
|
1 file changed, 13 insertions(+), 5 deletions(-)
|
2017-06-08 10:46:42 +00:00
|
|
|
|
|
|
|
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
|
2023-03-21 08:40:58 +00:00
|
|
|
index 4dc5a37b8..a977ba085 100644
|
2017-06-08 10:46:42 +00:00
|
|
|
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
|
|
|
|
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
|
2023-03-21 08:40:58 +00:00
|
|
|
@@ -31,21 +31,29 @@
|
|
|
|
public class LogbackConfiguration extends BaseSlf4jConfiguration {
|
2017-06-08 10:46:42 +00:00
|
|
|
@Override
|
2023-03-21 08:40:58 +00:00
|
|
|
public void setRootLoggerLevel(Level level) {
|
2017-06-08 10:46:42 +00:00
|
|
|
- ch.qos.logback.classic.Level value;
|
|
|
|
+ String value;
|
2023-03-21 08:40:58 +00:00
|
|
|
switch (level) {
|
2017-06-08 10:46:42 +00:00
|
|
|
case DEBUG:
|
|
|
|
- value = ch.qos.logback.classic.Level.DEBUG;
|
|
|
|
+ value = "DEBUG";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INFO:
|
|
|
|
- value = ch.qos.logback.classic.Level.INFO;
|
|
|
|
+ value = "INFO";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
- value = ch.qos.logback.classic.Level.ERROR;
|
|
|
|
+ value = "ERROR";
|
|
|
|
break;
|
|
|
|
}
|
2023-03-21 08:40:58 +00:00
|
|
|
- ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(value);
|
|
|
|
+ Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
|
2017-06-08 10:46:42 +00:00
|
|
|
+ try {
|
|
|
|
+ Class<?> levelClass = Class.forName("ch.qos.logback.classic.Level");
|
|
|
|
+ Object logbackLevel = levelClass.getField(value).get(null);
|
|
|
|
+ Class<?> loggerClass = Class.forName("ch.qos.logback.classic.Logger");
|
2023-03-21 08:40:58 +00:00
|
|
|
+ loggerClass.getMethod("setLevel", new Class<?>[] {levelClass}).invoke(logger, new Object[] {logbackLevel});
|
2017-06-08 10:46:42 +00:00
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException("Failed to initialize logback configuration", e);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
--
|
2023-03-21 08:40:58 +00:00
|
|
|
2.39.2
|
2017-06-08 10:46:42 +00:00
|
|
|
|