Repository navigation
Commit 8794f80
water
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
42 | 69 | | |
0 commit comments