Skip to content

Upgrade Log4j dependency to version 2.x.#748

Merged
blackwinter merged 4 commits into
masterfrom
739-upgradeLog4jDependency
Mar 26, 2026
Merged

Upgrade Log4j dependency to version 2.x.#748
blackwinter merged 4 commits into
masterfrom
739-upgradeLog4jDependency

Conversation

@blackwinter
Copy link
Copy Markdown
Member

Resolves #739.

The first three commits aren't directly related to the issue at hand, they just surfaced in the vicinity of the actual logging changes (final commit).

  • Changed logging provider from slf4j-log4j12 to log4j-slf4j2-impl.
  • Renamed and migrated configuration files (log4j.xml -> log4j2.xml) as well as system property (log4j.configuration -> log4j2.configurationFile).
  • Renamed console appenders from stdout/external-stdout to CONSOLE/EXTERNAL_CONSOLE.
  • Upgraded slf4j2-mock dependency to next minor version (although not required).
  • Avoided multiple logging providers from log4j-slf4j2-impl in combination with slf4j2-mock (see below):
    • Dropped testRuntimeOnly dependency for metafix project.
    • Moved implementation dependency for mwe2 configuration to proper dependencies block.

With both logging providers (even if only for mwe2):

> Task :metafix:test
MetafixScriptTest > shouldAbortProcessOnExecutionException() STANDARD_ERROR
    SLF4J(W): Class path contains multiple SLF4J providers.
    SLF4J(W): Found provider [org.apache.logging.slf4j.SLF4JServiceProvider@62ba3045]
    SLF4J(W): Found provider [org.simplify4u.slf4jmock.MockServiceProvider@397bd46b]
    SLF4J(W): See https://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J(I): Actual provider is of type [org.apache.logging.slf4j.SLF4JServiceProvider@62ba3045]

Without any logging provider for mwe2:

> Task :metafix:generateXtextLanguage
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.

`SimpleLogger` no longer used (removed in 5bea2c5, originally introduced in 0635657).
…afacture-fix#198)

Apparently, no longer needed since a7526fe (bisected; originally introduced in eecfdae).

```
> Task :metafix:jmh
[...]
SLF4J: Found binding in [jar:file:.../metafix/build/libs/metafix-0.2.0-SNAPSHOT-jmh.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:.../gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.21/.../slf4j-simple-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
```
Extending 5bea2c5 to include module and group; as well as unifying API dependency.
- Changed logging provider from `slf4j-log4j12` to `log4j-slf4j2-impl`.
- Renamed and migrated configuration files (`log4j.xml` -> `log4j2.xml`) as well as system property (`log4j.configuration` -> `log4j2.configurationFile`).
- Renamed console appenders from `stdout`/`external-stdout` to `CONSOLE`/`EXTERNAL_CONSOLE`.
- Upgraded `slf4j2-mock` dependency to next minor version (although not required).
- Avoided multiple logging providers from `log4j-slf4j2-impl` in combination with `slf4j2-mock` (see below):
  - Dropped `testRuntimeOnly` dependency for `metafix` project.
  - Moved `implementation` dependency for `mwe2` configuration to proper `dependencies` block.

With both logging providers (even if only for `mwe2`):

```
> Task :metafix:test
MetafixScriptTest > shouldAbortProcessOnExecutionException() STANDARD_ERROR
    SLF4J(W): Class path contains multiple SLF4J providers.
    SLF4J(W): Found provider [org.apache.logging.slf4j.SLF4JServiceProvider@62ba3045]
    SLF4J(W): Found provider [org.simplify4u.slf4jmock.MockServiceProvider@397bd46b]
    SLF4J(W): See https://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J(I): Actual provider is of type [org.apache.logging.slf4j.SLF4JServiceProvider@62ba3045]
```

Without any logging provider for `mwe2`:

```
> Task :metafix:generateXtextLanguage
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
```
@blackwinter
Copy link
Copy Markdown
Member Author

@fsteeg: Maybe you can already start your code review while @TobiasNx finishes his functional review? It doesn't look like there are any major complications to be expected at this point.

Copy link
Copy Markdown
Member

@fsteeg fsteeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great consolidation / cleanup in addition to the upgrade!

@fsteeg fsteeg assigned blackwinter and unassigned fsteeg Mar 24, 2026
@blackwinter blackwinter merged commit 7a64c15 into master Mar 26, 2026
2 checks passed
@blackwinter blackwinter deleted the 739-upgradeLog4jDependency branch March 26, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update log4j dependency

2 participants