3

Spring boot 1.5.8 by default providing logback-1.1.11 version. I am trying to upgrade the logback version from 1.1.11 to 1.3.0-alpha4 and added the below two properties in pom.

<slf4j.version>1.8.0-beta4</slf4j.version>
<logback.version>1.3.0-alpha4</logback.version>

Getting the below exception when i try to run the application.

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:273)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:98)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:230)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:209)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
    at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:292)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.anthem.acmp.service.UMIDALServiceApplication.main(UMIDALServiceApplication.java:25)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 14 more

I have found that the logback-classic-1.1.11.jar contains a package org.slf4j.impl which has the class StaticLoggerBinder, which is not available in logback-classic-1.3.0-alpha4 and causing this issue.

  • 1
    As the dependencies already mention those are beta and alpha releases of software. Things you generally don't want to use for production. Spring Boot has been build with SLF4J 1.7 in mind and not 1.8. Hence you probably run into compatibility issues. – M. Deinum Apr 18 '19 at 12:06

2 Answers2

2

Logback 1.3 and SLF4J 1.8 contain breaking API changes when compared with their 1.2 and 1.7 versions respectively. At the time of writing, Spring Boot is not compatible with the new API. There's an issue that is tracking support of the new versions. It won't be tackled until the projects have stabilised and are no longer in alpha or beta.

Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
1

I was able to use logback 1.3.0-alpha4 when I copied the StaticLoggerBinder from version 1.2 into my project. (Create a new StaticLoggerBinder.java in a new package org.slf4j.impl and paste the whole file.)

Itchy
  • 2,263
  • 28
  • 41