0
0
Spring Bootframework~10 mins

Package-level log configuration in Spring Boot - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Package-level log configuration
Start Application
Load application.properties
Read logging.level.package=value
Set log level for package
Run application code
Log messages filtered by package log level
Output logs accordingly
Spring Boot reads the logging level set for a package from configuration and applies it to filter log messages during runtime.
Execution Sample
Spring Boot
logging.level.com.example.service=DEBUG

// In code:
logger.debug("Debug message");
logger.info("Info message");
Sets DEBUG level logging for 'com.example.service' package, so debug and higher messages appear.
Execution Table
StepActionPackage Log LevelLog MessageMessage LevelOutput?
1Start applicationdefault INFO--No output
2Load config: logging.level.com.example.service=DEBUGcom.example.service=DEBUG--No output
3Run code in com.example.serviceDEBUGDebug messageDEBUGYes
4Run code in com.example.serviceDEBUGInfo messageINFOYes
5Run code in com.example.otherINFO (default)Debug messageDEBUGNo
6Run code in com.example.otherINFO (default)Info messageINFOYes
7End of execution---Stop logging
💡 Application finishes running; logging stops.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 6Final
packageLogLevel['com.example.service']INFO (default)DEBUGDEBUGDEBUGDEBUG
packageLogLevel['com.example.other']INFO (default)INFO (default)INFO (default)INFO (default)INFO (default)
Key Moments - 2 Insights
Why does a DEBUG log message in 'com.example.other' package not appear?
Because 'com.example.other' uses the default INFO level, which filters out DEBUG messages as shown in execution_table row 5.
How does Spring Boot know which log level to apply to a package?
It reads the 'logging.level.<package>' property from configuration before running code, as seen in step 2 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the log level for 'com.example.service' after loading configuration?
AERROR
BINFO
CDEBUG
DWARN
💡 Hint
Check Step 2 in the execution_table where config is loaded.
At which step does a DEBUG message from 'com.example.other' get filtered out?
AStep 5
BStep 3
CStep 4
DStep 6
💡 Hint
Look at Step 5 in the execution_table for 'com.example.other' package.
If we set 'logging.level.com.example.other=DEBUG', what changes in the execution table?
AStep 6 output changes to No
BStep 5 output changes to Yes
CStep 3 output changes to No
DNo changes
💡 Hint
Refer to variable_tracker and Step 5 output behavior.
Concept Snapshot
Package-level log configuration in Spring Boot:
- Set log level per package in application.properties using 'logging.level.<package>=LEVEL'
- Levels: TRACE < DEBUG < INFO < WARN < ERROR
- Messages below set level are filtered out
- Helps focus logs on specific parts of app
- Default level is INFO if not set
Full Transcript
This visual execution shows how Spring Boot applies package-level log configuration. When the application starts, it loads the logging.level properties from application.properties. For example, setting logging.level.com.example.service=DEBUG means all debug and higher messages in that package will be logged. The execution table traces steps where messages are logged or filtered based on package log levels. Variables track the current log level per package. Key moments clarify why some messages appear or not. The quiz tests understanding of how configuration affects logging output.