Skip to content

[LIVY-1090] Upgrade SLF4J 1.7.36 -> 2.0.17 (log4j-slf4j-impl -> log4j-slf4j2-impl) - #566

Open
roczei wants to merge 1 commit into
apache:masterfrom
roczei:upgrade_to_slf4j_2
Open

roczei wants to merge 1 commit into
apache:masterfrom
roczei:upgrade_to_slf4j_2

Conversation

@roczei

@roczei roczei commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

SLF4J 2.0.x replaced the 1.x StaticLoggerBinder lookup with a ServiceLoader-based SLF4JServiceProvider, so the Log4j 2 binding must be swapped from log4j-slf4j-impl (SLF4J 1.x) to log4j-slf4j2-impl (SLF4J 2.x).

  • pom.xml: slf4j.version 1.7.36 -> 2.0.17
  • Swap log4j-slf4j-impl -> log4j-slf4j2-impl in the binding declarations: root dependencyManagement, core, repl (provided), rsc (provided)
  • thriftserver/client: exclude log4j-slf4j-impl from hive-jdbc (hive-jdbc:3.0.0 still brings log4j-slf4j-impl:2.10.0) and declare log4j-slf4j2-impl explicitly
  • integration-test: additionally exclude log4j-slf4j2-impl from the test-scoped hive-jdbc, next to the existing log4j-slf4j-impl exclusion
  • thriftserver/server: replace the jetty-runner uber-jar (which bundles a shaded SLF4J 1.x that shadowed slf4j-api 2.x and caused a "Failed to load class org.slf4j.impl.StaticLoggerBinder" NOP fallback at server startup) with the individual jetty-server, jetty-servlet and jetty-webapp modules, and drop the now-obsolete jetty-util/jetty-xml/jetty-webapp excludeArtifactIds that only existed to avoid duplicating jetty-runner's bundled copies. The existing log4j-slf4j-impl exclusion on hive-jdbc is unchanged.

No Log4j bump needed (already on 2.26.0, >= the 2.23.0 minimum for log4j-slf4j2-impl). Livy has no org.slf4j.impl / StaticLoggerBinder usage, so no source changes are required.

JIRA: https://issues.apache.org/jira/browse/LIVY-1090

How was this patch tested?

Unit tests.

  • core/src/test/scala/org/apache/livy/LoggingSuite.scala: verifies a single SLF4JServiceProvider is registered and resolves to Log4j 2 (org.apache.logging.slf4j), and that messages logged through the Logging trait are routed to Log4j 2. Passes 2/2 on Scala 2.13 and test-compiles under Scala 2.12.
  • thriftserver/server/src/test/scala/org/apache/livy/thriftserver/TestThriftServerLogging.scala: asserts exactly one org.slf4j.LoggerFactory is on the classpath (fails if a shaded SLF4J such as jetty-runner is reintroduced) and that SLF4J binds to Log4j 2 rather than falling back to the NOP logger.

Also verified via mvn dependency:tree on core, repl, rsc, server, and thriftserver/server: slf4j-api resolves to 2.0.17, log4j-slf4j2-impl is present, and no log4j-slf4j-impl remains on the compile/runtime classpath (including under hive-jdbc). Started livy-server locally and confirmed the StaticLoggerBinder NOP warning is gone and logging works.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 4.8)

@roczei

roczei commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@gyogal / @ArnavBalyan

This PR is ready for review. Please take a look when you have a chance. Thanks!

@gyogal

gyogal commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Thanks for opening this PR @roczei, it is a nice update and another important modernization step. I ran a dependency tree and found a few leftover references to log4j-slf4j-impl leaking in in the thriftserver/client module:

[INFO] --------------------< org.apache.livy:livy-beeline >--------------------
[INFO] Building livy-beeline 1.0.0-SNAPSHOT                             [22/22]
[INFO]   from thriftserver/client/pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] Loaded 881 auto-discovered prefixes for remote repository ASF Staging (prefixes-ASF Staging.txt)
[INFO] Loaded 74 auto-discovered prefixes for remote repository ASF Snapshots (prefixes-ASF Snapshots.txt)
[INFO]·
[INFO] --- dependency:2.10:tree (default-cli) @ livy-beeline ---
...
[INFO] org.apache.livy:livy-beeline:pom:1.0.0-SNAPSHOT
[INFO] +- org.apache.hive:hive-jdbc:jar:3.0.0:compile
[INFO] |  +- org.apache.hive:hive-common:jar:3.0.0:compile
...
[INFO] |  |  +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.10.0:compile
...
[INFO] |  |  |  +- (org.apache.logging.log4j:log4j-slf4j-impl:jar:2.10.0:compile - omitted for duplicate)
...
[INFO] |  |  |  +- (org.apache.logging.log4j:log4j-slf4j-impl:jar:2.8.2:compile - omitted for conflict with 2.10.0)

Could you please check if this could/should be fixed as well?

@roczei
roczei force-pushed the upgrade_to_slf4j_2 branch from 996012f to a2671c4 Compare October 15, 2026 08:18
@roczei

roczei commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@gyogal

Thanks for the review! I've added the log4j-slf4j-impl exclusion to thriftserver/client/pom.xml.

Verified with dependency:tree, it's now completely gone:

$ mvn -Dverbose -Pthriftserver dependency:tree | grep log4j-slf4j-impl
$ 

</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change seems to solve the issue reported in LIVY-1092 as well.

@gyogal

gyogal commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Hi @roczei, it seems like there is still an issue with beeline. This is before the update:

❯ ls thriftserver/client/target/jars/log4j-slf4j-*
log4j-slf4j-impl-2.26.0.jar
❯ dev/beeline
Beeline version 3.0.0 by Apache Hive
beeline>

after the update:

❯ ls thriftserver/client/target/jars/log4j-slf4j-*
zsh: no matches found: thriftserver/client/target/jars/log4j-slf4j-*
❯ dev/beeline
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.
Beeline version 3.0.0 by Apache Hive
beeline>

Adding log4j-slf4j2-impl as a dependency in thriftserver/client/pom.xml fixed the issue locally, could you please update your PR if you agree with this solution?

…-slf4j2-impl)

## What changes were proposed in this pull request?

SLF4J 2.0.x replaced the 1.x StaticLoggerBinder lookup with a ServiceLoader-based
SLF4JServiceProvider, so the Log4j 2 binding must be swapped from log4j-slf4j-impl
(SLF4J 1.x) to log4j-slf4j2-impl (SLF4J 2.x).

- pom.xml: slf4j.version 1.7.36 -> 2.0.17
- Swap log4j-slf4j-impl -> log4j-slf4j2-impl in the binding declarations:
  root dependencyManagement, core, repl (provided), rsc (provided)
- thriftserver/client: exclude log4j-slf4j-impl from hive-jdbc (hive-jdbc:3.0.0 still
  brings log4j-slf4j-impl:2.10.0) and declare log4j-slf4j2-impl explicitly
- integration-test: additionally exclude log4j-slf4j2-impl from the test-scoped
  hive-jdbc (next to the existing log4j-slf4j-impl exclusion)
- thriftserver/server: replace the jetty-runner uber-jar (which bundles a shaded
  SLF4J 1.x that shadowed slf4j-api 2.x and caused a "Failed to load class
  org.slf4j.impl.StaticLoggerBinder" NOP fallback at server startup) with the
  individual jetty-server, jetty-servlet and jetty-webapp modules, and drop the
  now-obsolete jetty-util/jetty-xml/jetty-webapp excludeArtifactIds that only
  existed to avoid duplicating jetty-runner's bundled copies. The existing
  log4j-slf4j-impl exclusion on hive-jdbc is kept.

No Log4j bump needed (already on 2.26.0, >= the 2.23.0 minimum for log4j-slf4j2-impl).
Livy has no org.slf4j.impl / StaticLoggerBinder usage, so no source changes are required.

JIRA: https://issues.apache.org/jira/browse/LIVY-1090

## How was this patch tested?

Unit tests.
- core/src/test/scala/org/apache/livy/LoggingSuite.scala: verifies a single
  SLF4JServiceProvider is registered and resolves to Log4j 2 (org.apache.logging.slf4j),
  and that messages logged through the Logging trait are routed to Log4j 2. Passes 2/2
  on Scala 2.13 and test-compiles under Scala 2.12.
- thriftserver/server/src/test/scala/org/apache/livy/thriftserver/TestThriftServerLogging.scala:
  asserts exactly one org.slf4j.LoggerFactory is on the classpath (fails if a shaded
  SLF4J such as jetty-runner is reintroduced) and that SLF4J binds to Log4j 2 rather
  than falling back to the NOP logger.

Also verified via mvn dependency:tree on core, repl, rsc, server, and thriftserver/server:
slf4j-api resolves to 2.0.17, log4j-slf4j2-impl is present, and no log4j-slf4j-impl
remains on the compile/runtime classpath (including under hive-jdbc). Started livy-server
locally and confirmed the StaticLoggerBinder NOP warning is gone and logging works.

## Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 4.8)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@roczei
roczei force-pushed the upgrade_to_slf4j_2 branch from a2671c4 to 5e951c1 Compare October 16, 2026 16:06
@roczei

roczei commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

❯ ls thriftserver/client/target/jars/log4j-slf4j-*
zsh: no matches found: thriftserver/client/target/jars/log4j-slf4j-*
❯ dev/beeline
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.
Beeline version 3.0.0 by Apache Hive
beeline>


Adding `log4j-slf4j2-impl` as a dependency in `thriftserver/client/pom.xml` fixed the issue locally, could you please update your PR if you agree with this solution?

@gyogal

Good catch, thanks! I have just fixed it:

$ ./beeline 
Beeline version 3.0.0 by Apache Hive
beeline> 

This branch has not been deployed

No deployments
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