Skip to content

[#11683] Install JUL-to-SLF4J bridge to route java.util.logging through Maven logging#12345

Open
gnodet wants to merge 2 commits into
apache:maven-4.0.xfrom
gnodet:cherry-pick-11683-to-4.0.x
Open

[#11683] Install JUL-to-SLF4J bridge to route java.util.logging through Maven logging#12345
gnodet wants to merge 2 commits into
apache:maven-4.0.xfrom
gnodet:cherry-pick-11683-to-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of the JUL-to-SLF4J bridge fix to the maven-4.0.x branch.

Libraries that use java.util.logging (JUL) currently write their log output directly to stderr, bypassing Maven's logging configuration. This PR adds the jul-to-slf4j bridge so that JUL output is routed through SLF4J and Maven's logging system.

Changes

  • pom.xml: Add jul-to-slf4j to dependency management
  • apache-maven/pom.xml: Add jul-to-slf4j as a runtime dependency
  • impl/maven-cli/pom.xml: Add jul-to-slf4j dependency
  • LookupInvoker.java: Install SLF4JBridgeHandler at the start of activateLogging() to redirect JUL to SLF4J

Test plan

  • Verify build compiles with the new dependency
  • Run Maven with a plugin/library that uses JUL and confirm its log output goes through Maven's logging instead of raw stderr

🤖 Generated with Claude Code

… 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 <noreply@anthropic.com>
@gnodet gnodet added backport bug Something isn't working labels Jun 23, 2026
@gnodet gnodet added this to the 4.0.0-rc-6 milestone Jun 23, 2026
@gnodet gnodet requested review from cstamas and mthmulders June 23, 2026 10:31
@gnodet gnodet added the mvn40 label Jun 23, 2026
@gnodet gnodet requested a review from Copilot June 24, 2026 21:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR backports the JUL-to-SLF4J bridge to the maven-4.0.x line so that libraries emitting java.util.logging (JUL) output no longer bypass Maven’s SLF4J-based logging configuration.

Changes:

  • Adds org.slf4j:jul-to-slf4j to root dependency management.
  • Includes jul-to-slf4j in the Maven distribution and CLI module dependencies.
  • Installs SLF4JBridgeHandler during CLI logging activation to route JUL into SLF4J.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pom.xml Manages jul-to-slf4j version via ${slf4jVersion}.
apache-maven/pom.xml Ensures the distribution pulls in the JUL bridge at runtime.
impl/maven-cli/pom.xml Adds the CLI module dependency needed to compile/use SLF4JBridgeHandler.
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java Installs the JUL bridge during activateLogging().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +432 to +434
// Route java.util.logging (JUL) through SLF4J
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
Comment on lines +432 to +434
// Route java.util.logging (JUL) through SLF4J
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
Avoid redundantly removing handlers and reinstalling the
SLF4JBridgeHandler on every activateLogging() call, which matters
in embedded/resident-mode scenarios where Maven is invoked multiple
times in the same JVM.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants