|
| 1 | +# Log4j Migration Plan: websocket-server |
| 2 | + |
| 3 | +**Layer**: 7 (Application) — update after `parent-javalin-pom`, `oauth-token-manager`, and `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_JAVALIN_POM_VERSION` | What is the new `parent-javalin-pom` version? | |
| 12 | +| `NEW_JRE_UTILS_VERSION` | What is the new `jre-utils` version? | |
| 13 | +| `NEW_OAUTH_TOKEN_MANAGER_VERSION` | What is the new `oauth-token-manager` version? | |
| 14 | +| `OWN_NEW_VERSION` | What version should `websocket-server` be bumped to? (currently `1.0.19`) | |
| 15 | + |
| 16 | +## Context |
| 17 | + |
| 18 | +Part of a migration from Log4j 1.x to Log4j 2.25.3 across all libraries. Has 3 classes using `@Slf4j` — no code changes needed (SLF4J API is unchanged). This library inherits from `parent-javalin-pom` (not `parent-pom` directly). Both main and test configs suppress Jetty logging. |
| 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:websocket-server` |
| 25 | +- **Parent**: `parent-javalin-pom:1.0.2` |
| 26 | +- **In-house dependencies**: |
| 27 | + - `jre-utils:1.0.1` — bump to new version |
| 28 | + - `oauth-token-manager:1.0.11` — bump to new version |
| 29 | +- **log4j.properties**: YES (main + test, identical content) |
| 30 | +- **@Slf4j usage**: 3 classes |
| 31 | + |
| 32 | +### Current `log4j.properties` content (both main and test): |
| 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.eclipse.jetty=WARN |
| 42 | +``` |
| 43 | + |
| 44 | +## Steps |
| 45 | + |
| 46 | +### 1. Update parent version in `pom.xml` |
| 47 | + |
| 48 | +Change the parent version (line 8) to the new **parent-javalin-pom** version: |
| 49 | + |
| 50 | +```xml |
| 51 | +<parent> |
| 52 | + <groupId>info.unterrainer.commons</groupId> |
| 53 | + <artifactId>parent-javalin-pom</artifactId> |
| 54 | + <version>NEW_PARENT_JAVALIN_POM_VERSION</version> |
| 55 | +</parent> |
| 56 | +``` |
| 57 | + |
| 58 | +### 2. Update in-house dependency versions in `pom.xml` |
| 59 | + |
| 60 | +```xml |
| 61 | +<dependency> |
| 62 | + <groupId>info.unterrainer.commons</groupId> |
| 63 | + <artifactId>jre-utils</artifactId> |
| 64 | + <version>NEW_JRE_UTILS_VERSION</version> |
| 65 | +</dependency> |
| 66 | +<dependency> |
| 67 | + <groupId>info.unterrainer.commons</groupId> |
| 68 | + <artifactId>oauth-token-manager</artifactId> |
| 69 | + <version>NEW_OAUTH_TOKEN_MANAGER_VERSION</version> |
| 70 | +</dependency> |
| 71 | +``` |
| 72 | + |
| 73 | +### 3. Bump own version |
| 74 | + |
| 75 | +Increment `<version>` (line 13, currently `1.0.19`). |
| 76 | + |
| 77 | +### 4. Migrate logging config: create `src/main/resources/log4j2.xml` |
| 78 | + |
| 79 | +```xml |
| 80 | +<?xml version="1.0" encoding="UTF-8"?> |
| 81 | +<Configuration status="WARN"> |
| 82 | + <Appenders> |
| 83 | + <Console name="Console" target="SYSTEM_OUT"> |
| 84 | + <PatternLayout charset="UTF-8" |
| 85 | + pattern="%-4r [%t] %-5p %c %x - %m%n"/> |
| 86 | + </Console> |
| 87 | + </Appenders> |
| 88 | + <Loggers> |
| 89 | + <Logger name="io.netty" level="WARN"/> |
| 90 | + <Logger name="org.eclipse.milo" level="WARN"/> |
| 91 | + <Logger name="org.eclipse.jetty" level="WARN"/> |
| 92 | + <Root level="DEBUG"> |
| 93 | + <AppenderRef ref="Console"/> |
| 94 | + </Root> |
| 95 | + </Loggers> |
| 96 | +</Configuration> |
| 97 | +``` |
| 98 | + |
| 99 | +### 5. Migrate logging config: create `src/test/resources/log4j2-test.xml` |
| 100 | + |
| 101 | +```xml |
| 102 | +<?xml version="1.0" encoding="UTF-8"?> |
| 103 | +<Configuration status="WARN"> |
| 104 | + <Appenders> |
| 105 | + <Console name="Console" target="SYSTEM_OUT"> |
| 106 | + <PatternLayout charset="UTF-8" |
| 107 | + pattern="%-4r [%t] %-5p %c %x - %m%n"/> |
| 108 | + </Console> |
| 109 | + </Appenders> |
| 110 | + <Loggers> |
| 111 | + <Logger name="io.netty" level="WARN"/> |
| 112 | + <Logger name="org.eclipse.milo" level="WARN"/> |
| 113 | + <Logger name="org.eclipse.jetty" level="WARN"/> |
| 114 | + <Root level="DEBUG"> |
| 115 | + <AppenderRef ref="Console"/> |
| 116 | + </Root> |
| 117 | + </Loggers> |
| 118 | +</Configuration> |
| 119 | +``` |
| 120 | + |
| 121 | +### 6. Delete old config files |
| 122 | + |
| 123 | +- Delete `src/main/resources/log4j.properties` |
| 124 | +- Delete `src/test/resources/log4j.properties` |
| 125 | + |
| 126 | +### 7. Build, test, install |
| 127 | + |
| 128 | +```bash |
| 129 | +mvn clean install |
| 130 | +``` |
| 131 | + |
| 132 | +## Files Changed |
| 133 | + |
| 134 | +| File | Action | |
| 135 | +|------|--------| |
| 136 | +| `pom.xml` | Update parent-javalin-pom version, update jre-utils + oauth-token-manager versions, bump own version | |
| 137 | +| `src/main/resources/log4j2.xml` | Create (migrated from log4j.properties) | |
| 138 | +| `src/test/resources/log4j2-test.xml` | Create (migrated from log4j.properties) | |
| 139 | +| `src/main/resources/log4j.properties` | Delete | |
| 140 | +| `src/test/resources/log4j.properties` | Delete | |
0 commit comments