Debug logging in Spring Boot is used to generate detailed runtime information about the application's execution. It helps developers troubleshoot issues, understand application behavior, track bean initialization, inspect request processing, and diagnose configuration problems during development and testing.
Why Enable Debug Logging?
This makes troubleshooting significantly easier.
Method 1: Enable DEBUG Level Globally
The simplest approach is to set the root logging level.
logging.level.root=DEBUGAfter restarting the application, detailed logs will be generated for all components.
Method 2: Enable DEBUG for a Specific Package
Instead of logging everything, we can target a specific package.
logging.level.com.company.service=DEBUGOnly classes within the specified package will generate DEBUG logs.
This approach is preferred because it reduces log noise.
Method 3: Using application.yml
root: DEBUG
com.company.service: DEBUG
Method 4: Using Command-Line Arguments
java -jar app.jar --logging.level.root=DEBUGThis is useful when debugging without modifying configuration files.
Method 5: Using Spring Boot Debug Mode
Spring Boot provides a special debug flag.
debug=trueor
java -jar app.jar --debugThis enables additional startup diagnostics and auto-configuration reports.
Example Startup Output
This is extremely useful for troubleshooting startup issues.
How Logging Levels Work
TRACE
|
DEBUG
|
INFO
|
WARN
|
ERROR
DEBUG provides more details than INFO but fewer details than TRACE.
Common Logging Levels
TRACE
DEBUG
INFO
WARN
ERROR
Suppose a REST API is not connecting to the database.
logging.level.org.springframework.jdbc=DEBUG
This helps identify the exact cause of the issue.
Benefits of Debug Logging
Production Considerations
DEBUG logging generates a large amount of output.
Real-World Example
A Spring Boot application fails to start because a required bean is missing.
debug=true
This helps developers quickly identify and fix the problem.
A concise interview answer is
Debug logging in Spring Boot can be enabled by setting logging.level.root=DEBUG in application.properties or by using debug=true for additional startup diagnostics. It provides detailed runtime information that helps troubleshoot application behavior, configuration issues, and startup problems.
Last updated: 11 November 2026
Previous question: How can you check the environment properties of a Spring Boot application?
Next question: Why do you need the spring-boot-devtools dependency?