2022-04-21 20:36:30 +00:00
|
|
|
From 4d0c432cf88f2f70e6f793569d3dedace062fdef 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
|
2022-04-21 20:36:30 +00:00
|
|
|
Subject: [PATCH 2/6] Invoke logback via reflection
|
2017-06-08 10:46:42 +00:00
|
|
|
|
|
|
|
---
|
2018-06-28 14:42:23 +00:00
|
|
|
.../logging/impl/LogbackConfiguration.java | 19 ++++++++++++++-----
|
2017-06-08 10:46:42 +00:00
|
|
|
1 file changed, 14 insertions(+), 5 deletions(-)
|
|
|
|
|
|
|
|
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
|
2019-04-13 15:03:06 +00:00
|
|
|
index 5d9fab744..ced38cb5a 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
|
2019-04-13 15:03:06 +00:00
|
|
|
@@ -35,22 +35,31 @@
|
2017-06-08 10:46:42 +00:00
|
|
|
@Override
|
|
|
|
public void setRootLoggerLevel( Level level )
|
|
|
|
{
|
|
|
|
- ch.qos.logback.classic.Level value;
|
|
|
|
+ String value;
|
|
|
|
switch ( level )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
- ( (ch.qos.logback.classic.Logger) LoggerFactory.getLogger( Logger.ROOT_LOGGER_NAME ) ).setLevel( value );
|
|
|
|
+ Logger logger = LoggerFactory.getLogger( Logger.ROOT_LOGGER_NAME );
|
|
|
|
+ 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");
|
|
|
|
+ loggerClass.getMethod("setLevel", new Class<?>[] {levelClass})
|
|
|
|
+ .invoke(logger, new Object[] {logbackLevel});
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException("Failed to initialize logback configuration", e);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
--
|
2022-04-21 20:36:30 +00:00
|
|
|
2.35.1
|
2017-06-08 10:46:42 +00:00
|
|
|
|