Skip to content

Migrate logging API from SLF4J to Log4j 2.x#459

Merged
ppkarwasz merged 4 commits into
trunkfrom
migrate-logging-log4j2
Jun 17, 2026
Merged

Migrate logging API from SLF4J to Log4j 2.x#459
ppkarwasz merged 4 commits into
trunkfrom
migrate-logging-log4j2

Conversation

@ppkarwasz

Copy link
Copy Markdown
Member

Standardize all modules on the Log4j 2.x API so Flume's own logging no longer uses SLF4J. Applied the OpenRewrite Slf4jToLog4j recipe, then normalized the result: drop loggers that were never used, make every logger field private static final named "logger", and use the no-arg LogManager.getLogger() since each one named its own class.

Assisted-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Standardize all modules on the Log4j 2.x API so Flume's own logging no
longer goes through the SLF4J facade. Applied the OpenRewrite
Slf4jToLog4j recipe, then normalized the result: drop loggers that were
never used, make every logger field private static final named "logger",
and use the no-arg LogManager.getLogger() since each one named its own
class.

Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Dependencies frequently ship a logging backend or an API bridge as a
compile dependency, which then leaks to our consumers. Add a
maven-enforcer rule that bans every known logging implementation/bridge
and whitelists only the real logging APIs.

To satisfy the rule, drop the now-unneeded log4j-1.2-api (no Flume code
path reaches the Hadoop classes that use the org.apache.log4j API) and
exclude the logging backends that Hadoop (reload4j) and ZooKeeper
(logback) pull in. Exclusions live in dependencyManagement so they apply
wherever the dependency is used, and only where the artifact is actually
pulled; the enforcer rule catches anything reintroduced later.

Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The ban-logging rule whitelisted the whole log4j2 group, which let the
SLF4J 1.x binding (log4j-slf4j-impl) through. Switch the test bindings to
log4j-slf4j2-impl and import slf4j-bom so conflict resolution cannot
downgrade transitive SLF4J to 1.x.

Drop the log4j-jul and log4j-jcl bridges the tightened rule then flagged,
and manage commons-logging to a current release so transitive deps stop
pulling the ancient 1.2.

Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ppkarwasz

Copy link
Copy Markdown
Member Author

@rgoers,

I also banned all transitive logging dependencies that are not logging APIs, so Flume libraries don't leak artifacts like logback-core or log4j-slf4j2-impl to users. It will be up to users to decide whether they want to route Log4j API to SLF4J (log4j-to-slf4j) or the other way around (log4j-slf4j2-impl).

@ppkarwasz ppkarwasz merged commit 432a259 into trunk Jun 17, 2026
4 checks passed
@ppkarwasz ppkarwasz deleted the migrate-logging-log4j2 branch June 17, 2026 22:18
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.

2 participants