Spring boot does not load logback-spring.xml
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
When Spring Boot does not seem to load logback-spring.xml, the problem is usually one of four things: the file is not on the runtime classpath, another logging config is taking precedence, Logback is not actually the active logging system, or the XML uses Spring-specific features in a way that Logback loads too early to understand. The fix is usually straightforward once you check those possibilities in the right order.
What Spring Boot Actually Looks For
With Logback on the classpath, Spring Boot can pick up logging configuration from standard locations such as:
- '
classpath:logback-spring.xml' - '
classpath:logback.xml'
The -spring variant matters because it enables Spring Boot’s Logback extensions such as springProfile and springProperty.
A normal project layout should place the file here:
If it is somewhere else, Boot will not find it automatically unless you point to it explicitly.
A Minimal Working Example
This is a minimal logback-spring.xml that Spring Boot should load cleanly:
If even a file this simple is ignored, the issue is usually classpath placement, dependency conflicts, or a different config file being chosen first.
Check for Competing Configuration Files
One very common cause is having both of these present:
- '
logback.xml' - '
logback-spring.xml'
That can create confusion, especially if one file is packaged and the other is the one you are editing. If you want Spring Boot extensions, keep logback-spring.xml and remove unnecessary competing logging configs.
Also check for these other possibilities:
- '
logging.configproperty pointing somewhere else' - a different logging implementation such as Log4j2 on the classpath
- test resources overriding main resources
If another config location wins first, your logback-spring.xml may be fine but never used.
Use logging.config When Needed
If the file is not in the default location, point Spring Boot at it explicitly.
In application.properties:
Or via command line:
This is also useful when debugging, because it removes ambiguity about which file Boot should load.
logback-spring.xml Versus logback.xml
This distinction matters more than many people realize.
Use logback-spring.xml when you want Spring Boot-specific features such as:
- '
springProfile' - '
springProperty' - Boot-provided include resources
For example:
If you put Spring-specific tags into logback.xml, Logback may load the file too early and fail because Boot has not had a chance to apply its extensions.
Do Not Combine Spring Extensions with Logback Scanning
Another subtle issue is Logback configuration scanning. If you enable Logback's own scanning and also use Spring Boot Logback extensions, you can get confusing errors or behavior that looks like the file is not being loaded correctly.
In practice, if you are using logback-spring.xml, let Spring Boot manage that flow rather than layering in conflicting Logback scanning behavior.
Dependency Conflicts Matter
Spring Boot defaults to Logback when you use the standard starters, but if another logging stack is present, Boot may not be using Logback at all.
Check your dependencies for things such as:
- '
spring-boot-starter-log4j2' - explicit Log4j bridges or exclusions
- accidental removal of
spring-boot-starter-logging
If Logback is not the active backend, then logback-spring.xml cannot possibly control logging.
A Practical Debug Checklist
When the file seems ignored, check these in order:
- Is
logback-spring.xmlinsrc/main/resources - Is it actually packaged into the runtime artifact
- Is another logging config file taking precedence
- Is
logging.configpointing somewhere unexpected - Is Logback actually the active logging system
- Does the file use Spring tags that would fail in plain
logback.xml
This sequence solves most “Boot does not load my logging file” cases quickly.
Common Pitfalls
One common mistake is placing the file in the source tree but not in the resources directory, which means it never reaches the runtime classpath.
Another issue is editing logback-spring.xml while an older logback.xml or an explicit logging.config property is the file actually being used.
Developers also sometimes use springProfile or springProperty in logback.xml, which loads too early for those extensions to work correctly.
Finally, if Boot is actually using Log4j2 or another backend, no amount of editing Logback XML will change the result. Confirm the active logging system before digging into XML details.
Summary
- Put
logback-spring.xmlinsrc/main/resourcesunless you configure a different location explicitly. - Prefer
logback-spring.xmloverlogback.xmlwhen you need Spring Boot Logback extensions. - Check for competing config files and
logging.configoverrides. - Make sure Logback is actually the logging system on the classpath.
- Avoid mixing Spring Boot Logback extensions with incompatible early-loading or scanning assumptions.
Related reading
- Spring Boot enable http requests logging access logs
- Spring Boot How to add another WAR files to the embedded tomcat?
- Spring Boot Kafka health indicator
- Spring Boot, logback and logging.config property
- Spring boot doesn't load data to initialize database using data.sql
- Spring Boot embedded HornetQ cluster not forwarding messages
- Spring boot errorjava.lang.ArrayStoreException sun.reflect.annotation.TypeNotPresentExceptionProxy
- Spring boot fails to load DataSource using PostgreSQL driver

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.