You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/06/27 23:23:16 UTC
(maven) 01/02: [#11683] Install JUL-to-SLF4J bridge to route java.util.logging through Maven logging
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit da392652e0b687eebdb28dfe7e72f89b05bdc0e7
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Jun 23 07:17:58 2026 +0000
[#11683] Install JUL-to-SLF4J bridge to route java.util.logging through Maven logging
Adds the jul-to-slf4j bridge so that libraries using java.util.logging
(JUL) have their log output routed through SLF4J and Maven's logging
system, instead of writing directly to stderr.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
apache-maven/pom.xml | 7 +++++++
impl/maven-cli/pom.xml | 4 ++++
.../main/java/org/apache/maven/cling/invoker/LookupInvoker.java | 5 +++++
pom.xml | 5 +++++
4 files changed, 21 insertions(+)
diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index 9d32fb3cd7..c61af53502 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -78,6 +78,13 @@ under the License.
<version>${slf4jVersion}</version>
<scope>runtime</scope>
</dependency>
+ <!-- bridge from java.util.logging (JUL) to SLF4J -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ <version>${slf4jVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-connector-basic</artifactId>
diff --git a/impl/maven-cli/pom.xml b/impl/maven-cli/pom.xml
index 39b6fcaa5e..5d7304af5e 100644
--- a/impl/maven-cli/pom.xml
+++ b/impl/maven-cli/pom.xml
@@ -195,6 +195,10 @@ under the License.
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ </dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
index d29e09a5fc..bf2e0f8c65 100644
--- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
+++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
@@ -90,6 +90,7 @@
import org.jline.terminal.impl.AbstractPosixTerminal;
import org.jline.terminal.spi.TerminalExt;
import org.slf4j.LoggerFactory;
+import org.slf4j.bridge.SLF4JBridgeHandler;
import org.slf4j.spi.LocationAwareLogger;
import static java.util.Objects.requireNonNull;
@@ -428,6 +429,10 @@ protected Consumer<String> doDetermineWriter(C context) {
}
protected void activateLogging(C context) throws Exception {
+ // Route java.util.logging (JUL) through SLF4J
+ SLF4JBridgeHandler.removeHandlersForRootLogger();
+ SLF4JBridgeHandler.install();
+
context.slf4jConfiguration.activate();
if (context.options().failOnSeverity().isPresent()) {
String logLevelThreshold = context.options().failOnSeverity().get();
diff --git a/pom.xml b/pom.xml
index 337f6b862b..027a3dfa69 100644
--- a/pom.xml
+++ b/pom.xml
@@ -506,6 +506,11 @@ under the License.
<version>${slf4jVersion}</version>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ <version>${slf4jVersion}</version>
+ </dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>