1 Star 0 Fork 15

wang_yue111/maven

forked from src-openEuler/maven 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0002-Invoke-logback-via-reflection.patch 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
yaokai13 提交于 2020-09-03 18:13 . Fix the build error
From 4e1e32e3a96c6876a22cca6743288b8c8df4adb0 Mon Sep 17 00:00:00 2001
From: Michael Simacek <[email protected]>
Date: Tue, 6 Jun 2017 13:47:43 +0200
Subject: [PATCH 2/3] Invoke logback via reflection
---
.../logging/impl/LogbackConfiguration.java | 19 ++++++++++++++-----
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
index 5d9fab7..ced38cb 100644
--- 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
@@ -35,22 +35,31 @@ public class LogbackConfiguration
@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
--
2.17.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wang_yue111/maven.git
[email protected]:wang_yue111/maven.git
wang_yue111
maven
maven
master

搜索帮助