How do you enable debug logging in a Spring Boot application?

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.

Key Points

Why Enable Debug Logging?

Debug logs help developers understand

This makes troubleshooting significantly easier.

Method 1: Enable DEBUG Level Globally

The simplest approach is to set the root logging level.

logging.level.root=DEBUG

After 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=DEBUG

Only classes within the specified package will generate DEBUG logs.

This approach is preferred because it reduces log noise.

Method 3: Using application.yml

logging

level

root: DEBUG

Or for a specific package

logging

level

com.company.service: DEBUG

Method 4: Using Command-Line Arguments

java -jar app.jar --logging.level.root=DEBUG

This is useful when debugging without modifying configuration files.

Method 5: Using Spring Boot Debug Mode

Spring Boot provides a special debug flag.

debug=true
or

java -jar app.jar --debug

This enables additional startup diagnostics and auto-configuration reports.

Example Startup Output

When debug mode is enabled, Spring Boot displays information such as

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

Example

Suppose a REST API is not connecting to the database.

By enabling

logging.level.org.springframework.jdbc=DEBUG

Spring Boot logs

This helps identify the exact cause of the issue.

Benefits of Debug Logging

Production Considerations

DEBUG logging generates a large amount of output.

For production environments

Real-World Example

A Spring Boot application fails to start because a required bean is missing.

After enabling

debug=true

Spring Boot generates an auto-configuration report showing

This helps developers quickly identify and fix the problem.

Interview Tip

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?

More Spring Boot - Level I interview questions

All Spring Boot - Level I questions