|
| 1 | +# Log4j Migration Plan: mqtt-client |
| 2 | + |
| 3 | +**Layer**: 4 — update after `jre-utils` and `serialization`. |
| 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 | +| `NEW_SERIALIZATION_VERSION` | What is the new `serialization` version? | |
| 14 | +| `OWN_NEW_VERSION` | What version should `mqtt-client` be bumped to? (currently `1.0.0`) | |
| 15 | + |
| 16 | +## Context |
| 17 | + |
| 18 | +Part of a migration from Log4j 1.x to Log4j 2.25.3 across all libraries. Has 2 classes using `@Slf4j` — no code changes needed (SLF4J API is unchanged). |
| 19 | + |
| 20 | +> **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. |
| 21 | +
|
| 22 | +## Current State |
| 23 | + |
| 24 | +- **Artifact**: `info.unterrainer.commons:mqtt-client` |
| 25 | +- **Parent**: `parent-pom:1.0.1` |
| 26 | +- **In-house dependencies**: |
| 27 | + - `jre-utils:1.0.1` — bump to new version |
| 28 | + - `serialization:1.0.1` — bump to new version |
| 29 | +- **log4j.properties**: YES (main + test) |
| 30 | +- **@Slf4j usage**: 2 classes |
| 31 | + |
| 32 | +### Current `log4j.properties` content: |
| 33 | +```properties |
| 34 | +log4j.rootLogger=DEBUG, A1 |
| 35 | +log4j.appender.A1=org.apache.log4j.ConsoleAppender |
| 36 | +log4j.appender.A1.layout=org.apache.log4j.PatternLayout |
| 37 | +log4j.appender.A1.layout.charset=UTF-8 |
| 38 | +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n |
| 39 | +log4j.logger.io.netty=WARN |
| 40 | +log4j.logger.org.eclipse.milo=WARN |
| 41 | +log4j.logger.org.hibernate=WARN |
| 42 | +log4j.logger.com.mchange.v2.log.MLog=WARN |
| 43 | +log4j.logger.org.jboss.logging=WARN |
| 44 | +log4j.logger.liquibase.servicelocator=WARN |
| 45 | +log4j.logger.liquibase.resource=WARN |
| 46 | +log4j.logger.com.mchange.v2=WARN |
| 47 | +log4j.logger.org.eclipse.jetty=WARN |
| 48 | +log4j.logger.liquibase.util=WARN |
| 49 | +log4j.logger.liquibase.executor=WARN |
| 50 | +log4j.logger.org.hibernate=WARN |
| 51 | +``` |
| 52 | + |
| 53 | +## Steps |
| 54 | + |
| 55 | +### 1. Update parent version in `pom.xml` |
| 56 | + |
| 57 | +Change the parent version (line 7) to the new parent-pom version. |
| 58 | + |
| 59 | +### 2. Update in-house dependency versions in `pom.xml` |
| 60 | + |
| 61 | +```xml |
| 62 | +<dependency> |
| 63 | + <groupId>info.unterrainer.commons</groupId> |
| 64 | + <artifactId>jre-utils</artifactId> |
| 65 | + <version>NEW_JRE_UTILS_VERSION</version> |
| 66 | +</dependency> |
| 67 | +<dependency> |
| 68 | + <groupId>info.unterrainer.commons</groupId> |
| 69 | + <artifactId>serialization</artifactId> |
| 70 | + <version>NEW_SERIALIZATION_VERSION</version> |
| 71 | +</dependency> |
| 72 | +``` |
| 73 | + |
| 74 | +### 3. Bump own version |
| 75 | + |
| 76 | +Increment `<version>` (line 18, currently `1.0.0`). |
| 77 | + |
| 78 | +### 4. Create `src/main/resources/log4j2.xml` |
| 79 | + |
| 80 | +```xml |
| 81 | +<?xml version="1.0" encoding="UTF-8"?> |
| 82 | +<Configuration status="WARN"> |
| 83 | + <Appenders> |
| 84 | + <Console name="Console" target="SYSTEM_OUT"> |
| 85 | + <PatternLayout charset="UTF-8" |
| 86 | + pattern="%-4r [%t] %-5p %c %x - %m%n"/> |
| 87 | + </Console> |
| 88 | + </Appenders> |
| 89 | + <Loggers> |
| 90 | + <Logger name="io.netty" level="WARN"/> |
| 91 | + <Logger name="org.eclipse.milo" level="WARN"/> |
| 92 | + <Logger name="org.hibernate" level="WARN"/> |
| 93 | + <Logger name="com.mchange.v2.log.MLog" level="WARN"/> |
| 94 | + <Logger name="org.jboss.logging" level="WARN"/> |
| 95 | + <Logger name="liquibase.servicelocator" level="WARN"/> |
| 96 | + <Logger name="liquibase.resource" level="WARN"/> |
| 97 | + <Logger name="com.mchange.v2" level="WARN"/> |
| 98 | + <Logger name="org.eclipse.jetty" level="WARN"/> |
| 99 | + <Logger name="liquibase.util" level="WARN"/> |
| 100 | + <Logger name="liquibase.executor" level="WARN"/> |
| 101 | + <Root level="DEBUG"> |
| 102 | + <AppenderRef ref="Console"/> |
| 103 | + </Root> |
| 104 | + </Loggers> |
| 105 | +</Configuration> |
| 106 | +``` |
| 107 | + |
| 108 | +### 5. Create `src/test/resources/log4j2-test.xml` |
| 109 | + |
| 110 | +Same content as above. |
| 111 | + |
| 112 | +### 6. Delete old config files |
| 113 | + |
| 114 | +- Delete `src/main/resources/log4j.properties` |
| 115 | +- Delete `src/test/resources/log4j.properties` |
| 116 | + |
| 117 | +### 7. Build, test, install |
| 118 | + |
| 119 | +```bash |
| 120 | +mvn clean install |
| 121 | +``` |
| 122 | + |
| 123 | +## Files Changed |
| 124 | + |
| 125 | +| File | Action | |
| 126 | +|------|--------| |
| 127 | +| `pom.xml` | Update parent version, update jre-utils + serialization versions, bump own version | |
| 128 | +| `src/main/resources/log4j2.xml` | Create | |
| 129 | +| `src/test/resources/log4j2-test.xml` | Create | |
| 130 | +| `src/main/resources/log4j.properties` | Delete | |
| 131 | +| `src/test/resources/log4j.properties` | Delete | |
0 commit comments