0
0
Spring Bootframework~10 mins

Log levels (TRACE, DEBUG, INFO, WARN, ERROR) in Spring Boot - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Log levels (TRACE, DEBUG, INFO, WARN, ERROR)
Start Application
Log Event Occurs
Check Log Level Setting
Is Event Level >= Configured Level?
NoSkip Log
Write Log Message
Continue Application Execution
The application checks if the event's log level meets or exceeds the configured level. If yes, it writes the log message; otherwise, it skips logging.
Execution Sample
Spring Boot
logger.trace("Trace message");
logger.debug("Debug message");
logger.info("Info message");
logger.warn("Warn message");
logger.error("Error message");
Logs messages at different levels; only messages at or above the configured level are output.
Execution Table
StepLog CallConfigured LevelIs Log Level >= Configured?ActionOutput
1TRACEINFONoSkip LogNo output
2DEBUGINFONoSkip LogNo output
3INFOINFOYesWrite LogInfo message
4WARNINFOYesWrite LogWarn message
5ERRORINFOYesWrite LogError message
6----End of logging calls
💡 Logging stops after all log calls are checked against the configured level.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
Configured LevelINFOINFOINFOINFOINFOINFOINFO
Current Log Call-TRACEDEBUGINFOWARNERROR-
Log Output[][][]["Info message"]["Info message", "Warn message"]["Info message", "Warn message", "Error message"]["Info message", "Warn message", "Error message"]
Key Moments - 2 Insights
Why are TRACE and DEBUG messages not shown when the configured level is INFO?
Because TRACE and DEBUG are lower priority than INFO, the check in the execution_table rows 1 and 2 shows 'No' for 'Is Log Level >= Configured?', so these messages are skipped.
What happens if the configured level is set to ERROR?
Only ERROR messages will be logged because all other levels are lower priority. This is similar to the logic in the execution_table but with a higher configured level, causing more skips.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output after step 3?
A["Debug message"]
B["Info message"]
C[]
D["Trace message"]
💡 Hint
Check the 'Output' column at step 3 in the execution_table.
At which step does the log level first meet the configured level?
AStep 3
BStep 2
CStep 1
DStep 5
💡 Hint
Look at the 'Is Log Level >= Configured?' column in the execution_table.
If the configured level changes to DEBUG, which log calls will be output?
AINFO, WARN, ERROR
BTRACE, DEBUG, INFO, WARN, ERROR
CDEBUG, INFO, WARN, ERROR
DWARN, ERROR
💡 Hint
Compare the configured level in variable_tracker and think which levels are >= DEBUG.
Concept Snapshot
Log levels control which messages are recorded.
Levels in order: TRACE < DEBUG < INFO < WARN < ERROR.
Only messages at or above the configured level are logged.
Lower levels are skipped to reduce noise.
Configure level to control log detail and performance.
Full Transcript
In Spring Boot, log levels determine which messages are recorded. When the application runs, each log call is checked against the configured log level. If the message's level is equal or higher priority than the configured level, it is logged; otherwise, it is skipped. For example, if the configured level is INFO, TRACE and DEBUG messages are ignored, but INFO, WARN, and ERROR messages are shown. This helps control how much detail appears in logs, balancing information and noise. Changing the configured level changes which messages appear.