Backport Log API enhancements and mojo MDC to 4.0.x - #12690
Draft
gnodet wants to merge 1 commit into
Draft
Conversation
Backport four Log-related improvements from master to the 4.0.x branch
for inclusion in rc-7:
1. Log.trace() — new trace level (maps to SLF4J TRACE / JUL FINEST)
to separate Maven core internals from user-facing debug messages.
Currently -X floods debug output with resolver/interpolation details
that drown user-relevant diagnostics.
2. Log.child(name) — creates a sub-logger with an independently
filterable name (e.g. "CompilerMojo.diagnostics"), letting plugin
sub-components log under their own namespace.
3. Logger name alignment — Maven 4 Log now uses the mojo implementation
class name (e.g. "org.apache.maven.plugins.compiler.CompilerMojo")
instead of the goal name ("compiler:compile"). This matches what
Maven 3 mojos already use and enables standard SLF4J hierarchical
level configuration.
4. Mojo MDC propagation — sets "maven.mojo.id" (prefix:goal@executionId)
in the SLF4J MDC during mojo execution. All log messages — including
those arriving through the JUL-to-SLF4J bridge — now carry mojo
context, available to any SLF4J appender via %X{maven.mojo.id}.
Also fixes a pre-existing bug in DefaultLog where warn(Supplier, Throwable)
incorrectly delegated to logger.info() instead of logger.warn().
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport four Log-related improvements from master (#12572) to the 4.0.x branch for inclusion in rc-7:
Log.trace()— new trace level (SLF4J TRACE / JUL FINEST) to separate Maven core internals from user-facing debug messages. Currently-Xfloods debug output with resolver/interpolation details that drown user-relevant diagnostics.Log.child(name)— creates a sub-logger with an independently filterable name (e.g.CompilerMojo.diagnostics), letting plugin sub-components log under their own namespace.Lognow uses the mojo implementation class name (e.g.org.apache.maven.plugins.compiler.CompilerMojo) instead of the goal name (compiler:compile). This matches what Maven 3 mojos already use and enables standard SLF4J hierarchical level configuration.maven.mojo.id(prefix:goal@executionId) in the SLF4J MDC during mojo execution. All log messages — including those arriving through the JUL-to-SLF4J bridge — now carry mojo context, available to any SLF4J appender via%X{maven.mojo.id}.Also fixes a pre-existing bug where
DefaultLog.warn(Supplier, Throwable)delegated tologger.info()instead oflogger.warn().Files changed
Log.javatrace()methods +child()default methodDefaultLog.javaDefaultMavenPluginManager.javagetFullGoalName()→getImplementation()DefaultBuildPluginManager.javagetFullGoalName()→getImplementation()ProjectBuildLogAppender.javamaven.mojo.idMDC key +setMojoId()LoggingExecutionListener.javaTest plan
mvn test -pl impl/maven-corepasses locally🤖 Generated with Claude Code