What is package-level log configuration in Spring Boot?
It is setting the logging level (like INFO, DEBUG, ERROR) specifically for a Java package or namespace to control how much log detail is shown for that part of the application.
Click to reveal answer
beginner
How do you set a DEBUG log level for a package in Spring Boot's application.properties?
Add a line like logging.level.com.example.myapp=DEBUG where com.example.myapp is the package name.
Click to reveal answer
intermediate
What is the effect of setting logging.level.root=ERROR in Spring Boot?
It sets the default log level for all packages to ERROR, so only error messages show unless overridden by package-level settings.
Click to reveal answer
intermediate
Where can you configure package-level logging in Spring Boot besides application.properties?
You can also configure it in application.yml or programmatically using a logging framework like Logback or Log4j2 configuration files.
Click to reveal answer
beginner
Why is package-level log configuration useful in a Spring Boot app?
It helps focus on logs from specific parts of the app, making debugging easier without flooding logs with too much info from other packages.
Click to reveal answer
How do you set the log level for a specific package in Spring Boot using application.properties?
Alogging.level.<package>=LEVEL
Blog.package.<package>=LEVEL
Clogging.package.<package>=LEVEL
Dlog.level.<package>=LEVEL
✗ Incorrect
The correct syntax is logging.level.=LEVEL, for example logging.level.com.example=DEBUG.
What happens if you set logging.level.root=ERROR in Spring Boot?
ANo logs will be shown
BOnly ERROR and higher logs show for all packages by default
CAll logs including DEBUG show for all packages
DOnly INFO logs show for all packages
✗ Incorrect
Setting logging.level.root=ERROR means only error and more severe logs appear by default.
Which file can you NOT use to configure package-level logging in Spring Boot?
Apom.xml
Bapplication.yml
Clogback-spring.xml
Dapplication.properties
✗ Incorrect
pom.xml is for project dependencies, not logging configuration.
Why might you want to set DEBUG level only for one package?
ATo hide errors from that package
BTo disable logging for that package
CTo make the app run faster
DTo get detailed logs only from that package without cluttering logs from others
✗ Incorrect
Setting DEBUG for one package helps focus on detailed logs there without too much noise.
What is the default log level if none is set in Spring Boot?
AERROR
BDEBUG
CINFO
DWARN
✗ Incorrect
Spring Boot defaults to INFO level logging if no level is set.
Explain how to configure logging levels for specific packages in a Spring Boot application.
Think about how you control log detail for parts of your app.
You got /4 concepts.
Why is package-level log configuration helpful when debugging a Spring Boot app?
Imagine trying to find a problem in one part of a big app.
You got /4 concepts.
Practice
(1/5)
1. What is the purpose of setting logging.level.<package>=<level> in Spring Boot's application.properties?
easy
A. To control the logging detail for a specific Java package
B. To define the database connection URL
C. To set the server port number
D. To configure the application's timezone
Solution
Step 1: Understand the configuration key
The key logging.level.<package> is used to specify logging levels for Java packages in Spring Boot.
Step 2: Identify the purpose of this setting
This setting controls how detailed the logs are for that package, helping to focus on important logs and reduce noise.
Final Answer:
To control the logging detail for a specific Java package -> Option A
Quick Check:
Package-level log control = A [OK]
Hint: Remember: logging.level.package sets log detail per package [OK]
Common Mistakes:
Confusing logging level with server or database settings
Trying to set logging level without specifying a package
Using incorrect property keys like logging.package.level
2. Which of the following is the correct syntax to set the log level to DEBUG for the package com.example.service in application.properties?
easy
A. logging.level=com.example.service=DEBUG
B. log.level.com.example.service=DEBUG
C. logging.com.example.service.level=DEBUG
D. logging.level.com.example.service=DEBUG
Solution
Step 1: Recall the correct property format
The correct format is logging.level.<package>=<level>, so the package name comes immediately after logging.level..
Step 2: Match the option to the format
logging.level.com.example.service=DEBUG matches this format exactly: logging.level.com.example.service=DEBUG.
Final Answer:
logging.level.com.example.service=DEBUG -> Option D
Quick Check:
Correct syntax = B [OK]
Hint: Use logging.level.package=LEVEL exactly as shown [OK]
Common Mistakes:
Adding extra '=' signs in the property
Swapping order of package and level
Using 'log.level' instead of 'logging.level'
3. Given the following application.properties settings: logging.level.com.example=INFO logging.level.com.example.service=DEBUG What will be the log level for classes in com.example.service package?
medium
A. INFO
B. DEBUG
C. ERROR
D. WARN
Solution
Step 1: Understand package-level log hierarchy
More specific package settings override broader ones. Here, com.example.service is more specific than com.example.
Step 2: Determine effective log level
The com.example.service package is set to DEBUG, which overrides the INFO level set for com.example.
Final Answer:
DEBUG -> Option B
Quick Check:
Specific package level overrides general = C [OK]
Hint: More specific package log level overrides parent package [OK]
Common Mistakes:
Assuming parent package level applies to all subpackages
Ignoring more specific package settings
Confusing INFO and DEBUG levels
4. You set logging.level.com.example=TRACE in application.properties but still see only INFO logs from com.example classes. What is the most likely cause?
medium
A. Logging is disabled globally
B. TRACE level is not supported in Spring Boot
C. Another configuration overrides the log level to INFO
D. The package name is misspelled in the properties file
Solution
Step 1: Verify if TRACE is supported
TRACE is a valid log level in Spring Boot, so this is not the issue.
Step 2: Consider configuration overrides
If logs show INFO instead of TRACE, likely another config (like environment variables or YAML) overrides the level to INFO.
Final Answer:
Another configuration overrides the log level to INFO -> Option C
Quick Check:
Config override causes unexpected log level = D [OK]
Hint: Check for conflicting configs if log level seems ignored [OK]
Common Mistakes:
Assuming TRACE is unsupported
Not checking for typos in package name
Ignoring global logging settings
5. You want to reduce log noise by setting ERROR level for com.example.repository but keep DEBUG for com.example.service. Which application.properties configuration achieves this?
hard
A. logging.level.com.example.repository=ERROR
logging.level.com.example.service=DEBUG
B. logging.level.com.example=ERROR
logging.level.com.example.service=DEBUG
C. logging.level.com.example.repository=DEBUG
logging.level.com.example.service=ERROR
D. logging.level.com.example.repository=INFO
logging.level.com.example.service=DEBUG
Solution
Step 1: Set ERROR level specifically for repository package
Use logging.level.com.example.repository=ERROR to reduce noise from repository logs.
Step 2: Set DEBUG level specifically for service package
Use logging.level.com.example.service=DEBUG to keep detailed logs for service package.
Step 3: Combine both settings correctly
logging.level.com.example.repository=ERROR
logging.level.com.example.service=DEBUG correctly sets both packages with their respective levels in application.properties.
Final Answer:
logging.level.com.example.repository=ERROR
logging.level.com.example.service=DEBUG -> Option A
Quick Check:
Separate package levels set correctly = A [OK]
Hint: Set each package level separately for precise control [OK]
Common Mistakes:
Setting parent package level instead of specific packages
Swapping log levels between packages
Using incorrect property keys or syntax
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.