|
| 1 | +# Log4j Migration Plan: rdb-utils |
| 2 | + |
| 3 | +**Layer**: 4 — update after `jre-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_JRE_UTILS_VERSION` | What is the new `jre-utils` version? | |
| 13 | +| `OWN_NEW_VERSION` | What version should `rdb-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 7 classes using `@Slf4j` — no code changes needed (SLF4J API is unchanged). Has extended logger suppressions for Hibernate, Liquibase, and c3p0. |
| 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:rdb-utils` |
| 24 | +- **Parent**: `parent-pom:1.0.1` |
| 25 | +- **In-house dependencies**: |
| 26 | + - `jre-utils:1.0.1` — bump to new version |
| 27 | +- **log4j.properties**: YES (main + test) |
| 28 | +- **@Slf4j usage**: 7 classes |
| 29 | + |
| 30 | +### Current `log4j.properties` content (main): |
| 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.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n |
| 36 | +log4j.logger.io.netty=WARN |
| 37 | +log4j.logger.org.eclipse.milo=WARN |
| 38 | +log4j.logger.org.hibernate=WARN |
| 39 | +log4j.logger.com.mchange.v2.log.MLog=WARN |
| 40 | +log4j.logger.org.jboss.logging=WARN |
| 41 | +log4j.logger.liquibase.servicelocator=WARN |
| 42 | +log4j.logger.liquibase.resource=WARN |
| 43 | +log4j.logger.com.mchange.v2=WARN |
| 44 | +``` |
| 45 | + |
| 46 | +**Note**: No `charset=UTF-8` on the layout (unlike most others). |
| 47 | + |
| 48 | +## Steps |
| 49 | + |
| 50 | +### 1. Update parent version in `pom.xml` |
| 51 | + |
| 52 | +Change the parent version (line 7) to the new parent-pom version. |
| 53 | + |
| 54 | +### 2. Update in-house dependency versions in `pom.xml` |
| 55 | + |
| 56 | +```xml |
| 57 | +<dependency> |
| 58 | + <groupId>info.unterrainer.commons</groupId> |
| 59 | + <artifactId>jre-utils</artifactId> |
| 60 | + <version>NEW_JRE_UTILS_VERSION</version> |
| 61 | +</dependency> |
| 62 | +``` |
| 63 | + |
| 64 | +### 3. Bump own version |
| 65 | + |
| 66 | +Increment `<version>` (line 11, currently `1.0.0`). |
| 67 | + |
| 68 | +### 4. Create `src/main/resources/log4j2.xml` |
| 69 | + |
| 70 | +```xml |
| 71 | +<?xml version="1.0" encoding="UTF-8"?> |
| 72 | +<Configuration status="WARN"> |
| 73 | + <Appenders> |
| 74 | + <Console name="Console" target="SYSTEM_OUT"> |
| 75 | + <PatternLayout pattern="%-4r [%t] %-5p %c %x - %m%n"/> |
| 76 | + </Console> |
| 77 | + </Appenders> |
| 78 | + <Loggers> |
| 79 | + <Logger name="io.netty" level="WARN"/> |
| 80 | + <Logger name="org.eclipse.milo" level="WARN"/> |
| 81 | + <Logger name="org.hibernate" level="WARN"/> |
| 82 | + <Logger name="com.mchange.v2.log.MLog" level="WARN"/> |
| 83 | + <Logger name="org.jboss.logging" level="WARN"/> |
| 84 | + <Logger name="liquibase.servicelocator" level="WARN"/> |
| 85 | + <Logger name="liquibase.resource" level="WARN"/> |
| 86 | + <Logger name="com.mchange.v2" level="WARN"/> |
| 87 | + <Root level="DEBUG"> |
| 88 | + <AppenderRef ref="Console"/> |
| 89 | + </Root> |
| 90 | + </Loggers> |
| 91 | +</Configuration> |
| 92 | +``` |
| 93 | + |
| 94 | +### 5. Create `src/test/resources/log4j2-test.xml` |
| 95 | + |
| 96 | +Same content as above. |
| 97 | + |
| 98 | +### 6. Delete old config files |
| 99 | + |
| 100 | +- Delete `src/main/resources/log4j.properties` |
| 101 | +- Delete `src/test/resources/log4j.properties` |
| 102 | + |
| 103 | +### 7. Build, test, install |
| 104 | + |
| 105 | +```bash |
| 106 | +mvn clean install |
| 107 | +``` |
| 108 | + |
| 109 | +## Files Changed |
| 110 | + |
| 111 | +| File | Action | |
| 112 | +|------|--------| |
| 113 | +| `pom.xml` | Update parent version, update jre-utils version, bump own version | |
| 114 | +| `src/main/resources/log4j2.xml` | Create | |
| 115 | +| `src/test/resources/log4j2-test.xml` | Create | |
| 116 | +| `src/main/resources/log4j.properties` | Delete | |
| 117 | +| `src/test/resources/log4j.properties` | Delete | |
0 commit comments