Spring Boot stops during startup inside its Logback logging setup
Your error
java.lang.IllegalStateException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation3 more lines it can showFix it fast
Most common cause, 1 of 3A library brings a second SLF4J provider, and SLF4J binds to it
If you want Logback, exclude the extra provider from the dependency that drags it in.
<dependency>
<groupId>com.example</groupId>
<artifactId>library-that-brings-slf4j-simple</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>Short answer
LoggerFactory is not a Logback LoggerContext but Logback is on the classpath means SLF4J chose another backend, often Log4j 2 or slf4j-simple pulled in by a library, or a pinned slf4j-api 1.7 that cannot see Logback 1.3+. Keep exactly one SLF4J provider. Logback configuration error detected is different: Spring tags in logback.xml. Applies to Spring Boot 3.5 and 4.2.
Which cause do you have?
Print every SLF4J, Logback and Log4j artifact in the build. Then read the brackets of the startup error: Spring Boot names the factory class SLF4J actually bound to and the jar it came from.
mvn dependency:tree -Dincludes=org.slf4j,ch.qos.logback,org.apache.logging.log4jThen find the line you see in this list and open its fix:
- 1A library brings a second SLF4J provider, and SLF4J binds to it
The brackets in the message name a factory outside ch.qos.logback, such as a Log4j or slf4j-simple class, and the tree shows that jar under some other dependency - 2slf4j-api is held back at 1.7, which cannot find Logback 1.3 or newer
The tree shows org.slf4j:slf4j-api 1.7.x, startup prints SLF4J's Failed to load class org.slf4j.impl.StaticLoggerBinder warning, and the error names SLF4J's no-operation logger - 3logback.xml uses springProfile or springProperty
The exception reads Logback configuration error detected, and the lines under it point at a springProfile or springProperty element
What does the error look like?
java.lang.IllegalStateException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementationIf you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xmljava.lang.IllegalStateException: Logback configuration error detected:no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
Cause 1 of 3
A library brings a second SLF4J provider, and SLF4J binds to it
You seeThe brackets in the message name a factory outside ch.qos.logback, such as a Log4j or slf4j-simple class, and the tree shows that jar under some other dependency
Check
Spring Boot's default starters log through Logback, and LogbackLoggingSystem refuses to start when SLF4J hands it any other factory. SLF4J binds to one backend only; with two on the classpath it warns and the pick is effectively random. A library that declares log4j-slf4j2-impl, slf4j-simple or slf4j-reload4j as a normal dependency is enough to cause it.
mvn dependency:tree -Dincludes=org.slf4j:slf4j-simple,org.slf4j:slf4j-reload4j,org.apache.logging.log4j:log4j-slf4j2-implFix
If you want Logback, exclude the extra provider from the dependency that drags it in. If you really want Log4j 2, do the opposite and follow Boot's how-to: exclude spring-boot-starter-logging and add spring-boot-starter-log4j2.
<dependency>
<groupId>com.example</groupId>
<artifactId>library-that-brings-slf4j-simple</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>Verify
The tree shows logback-classic as the only SLF4J provider, and the application starts with Boot's normal console output.
mvn -q spring-boot:runConfirmed by slf4j.org
Cause 2 of 3
slf4j-api is held back at 1.7, which cannot find Logback 1.3 or newer
You seeThe tree shows org.slf4j:slf4j-api 1.7.x, startup prints SLF4J's Failed to load class org.slf4j.impl.StaticLoggerBinder warning, and the error names SLF4J's no-operation logger
Check
SLF4J 2 finds providers with ServiceLoader, while 1.7 looked for org.slf4j.impl.StaticLoggerBinder. The SLF4J error page states that Logback 1.3 and later do not ship that class and need slf4j-api 2.x. Paired with 1.7, SLF4J falls back to its NOP logger, which Spring Boot then rejects as a non-Logback factory.
mvn dependency:tree -Dincludes=org.slf4j:slf4j-apiFix
Remove the hand-set slf4j-api version, or the older BOM that sets it, so the version managed by Spring Boot wins. Boot 4.2.0 manages slf4j-api 2.0.20 beside logback-classic 1.6.6.
<!-- delete from <dependencyManagement> or <dependencies> -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>Verify
dependency:tree reports slf4j-api 2.0.x, the StaticLoggerBinder warning is gone, and the context starts.
mvn dependency:tree -Dincludes=org.slf4j:slf4j-apiConfirmed by slf4j.org
Cause 3 of 3
logback.xml uses springProfile or springProperty
You seeThe exception reads Logback configuration error detected, and the lines under it point at a springProfile or springProperty element
Check
Spring Boot's Logback extensions only work in logback-spring.xml or in a file named by logging.config, because the plain logback.xml is read before Spring is ready. Configuration scanning (scan="true") does not support the extensions either.
grep -nE "springProfile|springProperty|scan=" src/main/resources/logback*.xmlFix
Rename the file to logback-spring.xml so Spring Boot loads it after the environment exists, and remove scan="true" from the configuration element if the file uses the extensions.
git mv src/main/resources/logback.xml src/main/resources/logback-spring.xmlVerify
Start with a profile that a springProfile block targets; the block's settings apply and no configuration error is thrown.
mvn -q spring-boot:run -Dspring-boot.run.profiles=devConfirmed by docs.spring.io
How do I stop it coming back?
- Let Spring Boot manage slf4j-api, logback-classic and the Log4j modules; never give them versions of your own.
- Fail CI when the dependency tree contains a second SLF4J provider, using the same dependency:tree filter as the first step.
- Name the Logback file logback-spring.xml from the start, even before it uses any Spring tags.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro.