fix: restore Log4j2Plugins.dat in apm-toolkit-log4j-2.x - #825
Conversation
Since 9.5.0 the released apm-toolkit-log4j-2.x jar no longer contains META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat. Root cause: the root pom declares annotationProcessorPaths (Lombok only), which makes javac stop discovering annotation processors from the compile classpath. Log4j2's PluginProcessor from the provided log4j-core dependency never runs, so %traceId and %sw_ctx silently break. Declare the compiler plugin in this module with annotationProcessorPaths including both Lombok and log4j-core.
|
Could you update the changes.md about this? |
|
The fix is in the right place — module POM rather than root. Two notes on the form. 1. Prefer
|
Problem
Since 9.5.0, the released
apm-toolkit-log4j-2.xjar no longer contains the Log4j2 plugin descriptor:Without that descriptor Log4j2 cannot discover
TraceIdConverter, so%traceIdand%sw_ctxin aPatternLayoutsilently break — they are greedily matched as the built-in%t(thread name) followed by literal text.Verified against Maven Central:
Log4j2Plugins.datRoot Cause
9.5.0 added an
annotationProcessorPathsblock tomaven-compiler-pluginin the rootpom.xml, listing only Lombok. OnceannotationProcessorPathsis declared explicitly, javac stops discovering annotation processors from the compile classpath. Thelog4j-corejar is declared asprovidedin this module, and Log4j2'sPluginProcessor— previously picked up from that classpath — is what generatesLog4j2Plugins.dat. With the processor list narrowed to Lombok only,PluginProcessornever runs and the descriptor is silently dropped.Fix
Declare the compiler plugin in this module with
annotationProcessorPathscontaining both Lombok (preserving parent behaviour) andlog4j-core(restoring thePluginProcessor).Verification
The module's Java source files (
TraceIdConverter,SkyWalkingContextConverter,Log4j2OutputAppender,Log4j2SkyWalkingContextOutputAppender) do not use Lombok annotations, so adding it to the path is safe but optional.References