|
| 1 | +# Log4j Migration Plan: parent-pom |
| 2 | + |
| 3 | +**Layer**: 0 (Root) — update this FIRST, before all other libraries. |
| 4 | + |
| 5 | +## Before Starting |
| 6 | + |
| 7 | +Prompt the user for the following version numbers before making any changes: |
| 8 | + |
| 9 | +| Variable | Question | |
| 10 | +|----------|----------| |
| 11 | +| `OWN_NEW_VERSION` | What version should `parent-pom` be bumped to? (currently check `<version>` in pom.xml) | |
| 12 | + |
| 13 | +## Context |
| 14 | + |
| 15 | +This is the root parent POM inherited by all libraries. It currently declares `slf4j-log4j12` and `slf4j-simple` as logging backends. This migration replaces them with Log4j 2.25.3, which propagates to every child project automatically. |
| 16 | + |
| 17 | +## Current State |
| 18 | + |
| 19 | +- **Artifact**: `info.unterrainer.commons:parent-pom` |
| 20 | +- **Local version**: check `<version>` in `pom.xml` (bump it after changes) |
| 21 | +- **Logging deps** (lines 39-54): |
| 22 | + - `org.slf4j:slf4j-api:2.0.17` (KEEP) |
| 23 | + - `org.slf4j:slf4j-log4j12:2.0.17` (REMOVE) |
| 24 | + - `org.slf4j:slf4j-simple:2.0.17` (REMOVE) |
| 25 | +- **Plugin config** (`maven-dependency-plugin`, lines 206-208): |
| 26 | + - `ignoredUnusedDeclaredDependency` entries for `slf4j-log4j12` and `slf4j-simple` (REPLACE) |
| 27 | + |
| 28 | +## Steps |
| 29 | + |
| 30 | +### 1. Replace logging dependencies in `pom.xml` |
| 31 | + |
| 32 | +In the `<dependencies>` section, **remove**: |
| 33 | + |
| 34 | +```xml |
| 35 | +<!-- REMOVE these two --> |
| 36 | +<dependency> |
| 37 | + <groupId>org.slf4j</groupId> |
| 38 | + <artifactId>slf4j-log4j12</artifactId> |
| 39 | + <version>2.0.17</version> |
| 40 | +</dependency> |
| 41 | +<dependency> |
| 42 | + <groupId>org.slf4j</groupId> |
| 43 | + <artifactId>slf4j-simple</artifactId> |
| 44 | + <version>2.0.17</version> |
| 45 | +</dependency> |
| 46 | +``` |
| 47 | + |
| 48 | +**Keep** `slf4j-api` unchanged. **Add** after it: |
| 49 | + |
| 50 | +```xml |
| 51 | +<dependency> |
| 52 | + <groupId>org.apache.logging.log4j</groupId> |
| 53 | + <artifactId>log4j-api</artifactId> |
| 54 | + <version>2.25.3</version> |
| 55 | +</dependency> |
| 56 | +<dependency> |
| 57 | + <groupId>org.apache.logging.log4j</groupId> |
| 58 | + <artifactId>log4j-core</artifactId> |
| 59 | + <version>2.25.3</version> |
| 60 | +</dependency> |
| 61 | +<dependency> |
| 62 | + <groupId>org.apache.logging.log4j</groupId> |
| 63 | + <artifactId>log4j-slf4j2-impl</artifactId> |
| 64 | + <version>2.25.3</version> |
| 65 | +</dependency> |
| 66 | +``` |
| 67 | + |
| 68 | +### 2. Update `ignoredUnusedDeclaredDependencies` in plugin config |
| 69 | + |
| 70 | +In the `maven-dependency-plugin` `<configuration>`, **remove**: |
| 71 | + |
| 72 | +```xml |
| 73 | +<ignoredUnusedDeclaredDependency>org.slf4j:slf4j-log4j12</ignoredUnusedDeclaredDependency> |
| 74 | +<ignoredUnusedDeclaredDependency>org.slf4j:slf4j-simple</ignoredUnusedDeclaredDependency> |
| 75 | +``` |
| 76 | + |
| 77 | +**Add**: |
| 78 | + |
| 79 | +```xml |
| 80 | +<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-api</ignoredUnusedDeclaredDependency> |
| 81 | +<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-core</ignoredUnusedDeclaredDependency> |
| 82 | +<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-slf4j2-impl</ignoredUnusedDeclaredDependency> |
| 83 | +``` |
| 84 | + |
| 85 | +### 3. Bump version |
| 86 | + |
| 87 | +Increment the `<version>` tag. This is a breaking backend change — consider a minor/major bump. |
| 88 | + |
| 89 | +### 4. Build and install locally |
| 90 | + |
| 91 | +```bash |
| 92 | +mvn clean install |
| 93 | +``` |
| 94 | + |
| 95 | +### 5. Verify |
| 96 | + |
| 97 | +```bash |
| 98 | +mvn dependency:tree -Dincludes="*log4j*,*slf4j*,*reload4j*" |
| 99 | +``` |
| 100 | + |
| 101 | +Must show: `slf4j-api`, `log4j-api`, `log4j-core`, `log4j-slf4j2-impl`. |
| 102 | +Must NOT show: `slf4j-log4j12`, `slf4j-reload4j`, `slf4j-simple`, `reload4j`. |
| 103 | + |
| 104 | +## Files Changed |
| 105 | + |
| 106 | +| File | Action | |
| 107 | +|------|--------| |
| 108 | +| `pom.xml` | Replace logging deps, update plugin config, bump version | |
0 commit comments