|
| 1 | +# Log4j Migration Plan: jre-utils |
| 2 | + |
| 3 | +**Layer**: 3 — update after `cli-utils`. |
| 4 | + |
| 5 | +## Before Starting |
| 6 | + |
| 7 | +Prompt the user for the following version numbers before making any changes: |
| 8 | + |
| 9 | +| Variable | Question | |
| 10 | +|----------|----------| |
| 11 | +| `NEW_PARENT_POM_VERSION` | What is the new `parent-pom` version? | |
| 12 | +| `NEW_CLI_UTILS_VERSION` | What is the new `cli-utils` version? | |
| 13 | +| `OWN_NEW_VERSION` | What version should `jre-utils` be bumped to? (currently `1.0.0`) | |
| 14 | + |
| 15 | +## Context |
| 16 | + |
| 17 | +Part of a migration from Log4j 1.x to Log4j 2.25.3 across all libraries. Has 4 classes using `@Slf4j` — no code changes needed (SLF4J API is unchanged). |
| 18 | + |
| 19 | +> **IMPORTANT for execution**: This plan should be executed by actually making the file changes described below — create the new `log4j2.xml` / `log4j2-test.xml` files with the content provided, and delete the old `log4j.properties` files. Do not leave the config migration as a manual step. |
| 20 | +
|
| 21 | +## Current State |
| 22 | + |
| 23 | +- **Artifact**: `info.unterrainer.commons:jre-utils` |
| 24 | +- **Parent**: `parent-pom:1.0.1` |
| 25 | +- **In-house dependencies**: |
| 26 | + - `cli-utils:1.0.1` — bump to new version |
| 27 | +- **log4j.properties**: YES (main + test) |
| 28 | +- **@Slf4j usage**: 4 classes |
| 29 | + |
| 30 | +### Current `log4j.properties` content: |
| 31 | +```properties |
| 32 | +log4j.rootLogger=DEBUG, A1 |
| 33 | +log4j.appender.A1=org.apache.log4j.ConsoleAppender |
| 34 | +log4j.appender.A1.layout=org.apache.log4j.PatternLayout |
| 35 | +log4j.appender.A1.layout.charset=UTF-8 |
| 36 | +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n |
| 37 | +log4j.logger.io.netty=WARN |
| 38 | +log4j.logger.org.eclipse.milo=WARN |
| 39 | +``` |
| 40 | + |
| 41 | +## Steps |
| 42 | + |
| 43 | +### 1. Update parent version in `pom.xml` |
| 44 | + |
| 45 | +Change the parent version (line 8) to the new parent-pom version. |
| 46 | + |
| 47 | +### 2. Update in-house dependency versions in `pom.xml` |
| 48 | + |
| 49 | +```xml |
| 50 | +<dependency> |
| 51 | + <groupId>info.unterrainer.commons</groupId> |
| 52 | + <artifactId>cli-utils</artifactId> |
| 53 | + <version>NEW_CLI_UTILS_VERSION</version> |
| 54 | +</dependency> |
| 55 | +``` |
| 56 | + |
| 57 | +### 3. Bump own version |
| 58 | + |
| 59 | +Increment `<version>` (line 12, currently `1.0.0`). |
| 60 | + |
| 61 | +### 4. Create `src/main/resources/log4j2.xml` |
| 62 | + |
| 63 | +```xml |
| 64 | +<?xml version="1.0" encoding="UTF-8"?> |
| 65 | +<Configuration status="WARN"> |
| 66 | + <Appenders> |
| 67 | + <Console name="Console" target="SYSTEM_OUT"> |
| 68 | + <PatternLayout charset="UTF-8" |
| 69 | + pattern="%-4r [%t] %-5p %c %x - %m%n"/> |
| 70 | + </Console> |
| 71 | + </Appenders> |
| 72 | + <Loggers> |
| 73 | + <Logger name="io.netty" level="WARN"/> |
| 74 | + <Logger name="org.eclipse.milo" level="WARN"/> |
| 75 | + <Root level="DEBUG"> |
| 76 | + <AppenderRef ref="Console"/> |
| 77 | + </Root> |
| 78 | + </Loggers> |
| 79 | +</Configuration> |
| 80 | +``` |
| 81 | + |
| 82 | +### 5. Create `src/test/resources/log4j2-test.xml` |
| 83 | + |
| 84 | +Same content as above. |
| 85 | + |
| 86 | +### 6. Delete old config files |
| 87 | + |
| 88 | +- Delete `src/main/resources/log4j.properties` |
| 89 | +- Delete `src/test/resources/log4j.properties` |
| 90 | + |
| 91 | +### 7. Build, test, install |
| 92 | + |
| 93 | +```bash |
| 94 | +mvn clean install |
| 95 | +``` |
| 96 | + |
| 97 | +## Files Changed |
| 98 | + |
| 99 | +| File | Action | |
| 100 | +|------|--------| |
| 101 | +| `pom.xml` | Update parent version, update cli-utils version, bump own version | |
| 102 | +| `src/main/resources/log4j2.xml` | Create | |
| 103 | +| `src/test/resources/log4j2-test.xml` | Create | |
| 104 | +| `src/main/resources/log4j.properties` | Delete | |
| 105 | +| `src/test/resources/log4j.properties` | Delete | |
0 commit comments