Projects
Mega:24.03
maven
_service:tar_scm:0002-invoke-logback-via-reflec...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0002-invoke-logback-via-reflection.patch of Package maven
From 3ce790eaafcf42e8720c778b712345f100064f38 Mon Sep 17 00:00:00 2001 From: Michael Simacek <msimacek@redhat.com> Date: Mon, 25 May 2020 12:12:15 +0200 Subject: [PATCH 2/4] 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 d16eaa9..51274eb 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.26.2
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2