Skip to content

Commit 8794f80

Browse files
author
water
authored
fix: restore Log4j2Plugins.dat in apm-toolkit-log4j-2.x (#825)
### Problem Since **9.5.0**, the released `apm-toolkit-log4j-2.x` jar no longer contains the Log4j2 plugin descriptor: ``` META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat ``` Without that descriptor Log4j2 cannot discover `TraceIdConverter`, so `%traceId` and `%sw_ctx` in a `PatternLayout` silently break — they are greedily matched as the built-in `%t` (thread name) followed by literal text. Verified against Maven Central: | Version | `Log4j2Plugins.dat` | |---------|---------------------| | 9.0.0 – 9.4.0 | present | | 9.5.0 – 9.7.0 | **missing** | ### Root Cause 9.5.0 added an `annotationProcessorPaths` block to `maven-compiler-plugin` in the root `pom.xml`, listing only Lombok. Once `annotationProcessorPaths` is declared explicitly, javac stops discovering annotation processors from the compile classpath. The `log4j-core` jar is declared as `provided` in this module, and Log4j2's `PluginProcessor` — previously picked up from that classpath — is what generates `Log4j2Plugins.dat`. With the processor list narrowed to Lombok only, `PluginProcessor` never runs and the descriptor is silently dropped. ### Fix Declare the compiler plugin in this module with `annotationProcessorPaths` containing both Lombok (preserving parent behaviour) and `log4j-core` (restoring the `PluginProcessor`).
1 parent a0c1155 commit 8794f80

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎CHANGES.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Release Notes.
66
------------------
77

88
* Add Spring LDAP 3.3.x-4.x plugin.
9+
* Fix the Log4j2 plugin descriptor (`Log4j2Plugins.dat`) missing from the `apm-toolkit-log4j-2.x` jar since 9.5.0, which broke `%traceId` and `%sw_ctx` resolution in Log4j2 `PatternLayout` (apache/skywalking#14006).
910

1011
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/263?closed=1)
1112

‎apm-application-toolkit/apm-toolkit-log4j-2.x/pom.xml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,31 @@
3939
<scope>provided</scope>
4040
</dependency>
4141
</dependencies>
42+
43+
<build>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-compiler-plugin</artifactId>
48+
<configuration>
49+
<!--
50+
The root POM declares annotationProcessorPaths, which makes
51+
javac stop discovering processors from the classpath.
52+
Append log4j-core's PluginProcessor (which generates
53+
Log4j2Plugins.dat) so that %traceId / %sw_ctx resolve to the
54+
toolkit converters instead of built-in Log4j2 patterns.
55+
combine.children="append" keeps the Lombok entry inherited
56+
from the root POM.
57+
-->
58+
<annotationProcessorPaths combine.children="append">
59+
<path>
60+
<groupId>org.apache.logging.log4j</groupId>
61+
<artifactId>log4j-core</artifactId>
62+
<version>${log4j-core.version}</version>
63+
</path>
64+
</annotationProcessorPaths>
65+
</configuration>
66+
</plugin>
67+
</plugins>
68+
</build>
4269
</project>

0 commit comments

Comments
 (0)