Upgrade slf4j to 2.0.0
See original GitHub issueslf4j has recently been upgraded by a major version, in order to use current versions of dependent libraries (logback-core, logback-classic) we need playframework to upgrade the version of slf4j to 2.0.0 as well.
Play Version
2.8.16
API
scala
Operating System
Mac
JDK
Library Dependencies
logback-classic, logback-core 1.4.0
Expected Behavior
The server is able to initialise
Actual Behavior
The server cannot startup because the version of slf4j is incompatible
[error] java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
[error] at play.api.libs.logback.LogbackLoggerConfigurator.loggerFactory(LogbackLoggerConfigurator.scala:21)
[error] at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:84)
[error] at play.api.libs.logback.LogbackLoggerConfigurator.init(LogbackLoggerConfigurator.scala:31)
[error] at play.core.server.DevServerStart$.$anonfun$mainDev$1(DevServerStart.scala:106)
[error] at play.utils.Threads$.withContextClassLoader(Threads.scala:22)
[error] at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:76)
[error] at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
[error] at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[error] at play.runsupport.Reloader$.startDevMode(Reloader.scala:306)
[error] at play.sbt.run.PlayRun$.devModeServer$lzycompute$1(PlayRun.scala:100)
[error] at play.sbt.run.PlayRun$.devModeServer$1(PlayRun.scala:83)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:107)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:67)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
[error] at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
[error] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
[error] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
[error] at play.api.libs.logback.LogbackLoggerConfigurator.loggerFactory(LogbackLoggerConfigurator.scala:21)
[error] at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:84)
[error] at play.api.libs.logback.LogbackLoggerConfigurator.init(LogbackLoggerConfigurator.scala:31)
[error] at play.core.server.DevServerStart$.$anonfun$mainDev$1(DevServerStart.scala:106)
[error] at play.utils.Threads$.withContextClassLoader(Threads.scala:22)
[error] at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:76)
[error] at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
[error] at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[error] at play.runsupport.Reloader$.startDevMode(Reloader.scala:306)
[error] at play.sbt.run.PlayRun$.devModeServer$lzycompute$1(PlayRun.scala:100)
[error] at play.sbt.run.PlayRun$.devModeServer$1(PlayRun.scala:83)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:107)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:67)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
SLF4J News
SLF4J version 2.0.0 requires Java 8. It builds on the 1.8.x series and adds a backward-compatible fluent logging api. By backward-compatible, we mean...
Read more >Upgrade slf4j-api to 2.0 · Issue #1034 · slackapi/java-slack-sdk
slf4j project released a new major version - 2.0. According to the migration guide, it's safe to upgrade the dependency in this project...
Read more >Is slf4j 2.0.0-alpha7 compatible with log4j 2.17.2?
0-alpha2 compatible with Log4j 2.8.2. I am trying to upgrade from slf4j 1.7.36 to 2.0.0-alpha7. Currently I have this in my POM:
Read more >Log4j 2 SLF4J Binding - Apache Logging Services
The SLF4J binding provided in this component cause all the SLF4J APIs to be routed to Log4j 2. Simply include the Log4j 2...
Read more >SLF4J 2.0.0 released : r/java - Reddit
SLF4J 2.0.0 released ... Looks like we finally have a stable version that supports modules. ... Read the announcement in the qos.ch-announce mailing ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @jfsoul, can you provide a pull request with your change?
@mkurz I had a quick look and I’m wondering whether we can resolve on
2.8.x
fairly simply after all.In https://github.com/playframework/playframework/compare/2.8.x...jfsoul:playframework:2.8.x if we replace the direct reference to
StaticLoggerBinder
with call to the factory method, then we should be able to work with SLF4J 1 or 2 because the factory finds the logging backend for us.It looks like that used to be the way it was done until this change although I don’t understand the reason for changing to use
StaticLoggerBinder
directly, so I’m a little hesitant.I can spend a bit more time on it and PR, if this sounds reasonable.