Bird
Raised Fist0
Spring Bootframework~20 mins

Log levels (TRACE, DEBUG, INFO, WARN, ERROR) in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Log Level Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What log messages appear at INFO level?
Given the Spring Boot application configured with log level INFO, which log messages will be printed to the console?
Spring Boot
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogExample {
    private static final Logger logger = LoggerFactory.getLogger(LogExample.class);

    public static void main(String[] args) {
        logger.trace("Trace message");
        logger.debug("Debug message");
        logger.info("Info message");
        logger.warn("Warn message");
        logger.error("Error message");
    }
}
AOnly 'Error message' is printed.
BOnly 'Info message', 'Warn message', and 'Error message' are printed.
CAll messages from 'Trace message' to 'Error message' are printed.
DOnly 'Warn message' and 'Error message' are printed.
Attempts:
2 left
💡 Hint
INFO level shows messages at INFO and above severity.
📝 Syntax
intermediate
1:30remaining
Which log level setting disables all logging?
In Spring Boot's application.properties, which log level setting disables all logging output?
Alogging.level.root=OFF
Blogging.level.root=ERROR
Clogging.level.root=DISABLE
Dlogging.level.root=NONE
Attempts:
2 left
💡 Hint
Check the official log level names for disabling logs.
🔧 Debug
advanced
2:30remaining
Why does DEBUG log not appear despite setting DEBUG level?
A developer sets logging.level.com.example=DEBUG in application.properties but DEBUG messages from com.example.service.MyService do not appear. What is the most likely cause?
AThe root log level is set to ERROR, which overrides package settings.
BThe application.properties file is not loaded at runtime.
CThe logging framework does not support DEBUG level.
DThe logger in MyService is using a different package name than com.example.service.
Attempts:
2 left
💡 Hint
Check the exact package name used in the logger declaration.
🧠 Conceptual
advanced
2:00remaining
What is the order of log levels from most to least detailed?
Arrange the log levels from the most detailed (shows most messages) to the least detailed (shows fewest messages).
A1,2,3,4,5
B5,4,3,2,1
C3,2,1,4,5
D2,1,3,4,5
Attempts:
2 left
💡 Hint
TRACE logs everything, ERROR logs only errors.
❓ state_output
expert
3:00remaining
What is the output count of WARN and ERROR logs with mixed package levels?
Given these log level settings in application.properties: logging.level.com.example=DEBUG logging.level.com.example.service=ERROR And this code: import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyService { private static final Logger logger = LoggerFactory.getLogger(MyService.class); public void run() { logger.debug("Debug message"); logger.info("Info message"); logger.warn("Warn message"); logger.error("Error message"); } } How many log messages will be printed when run() is called?
A'Debug', 'Info', 'Warn', and 'Error' messages are printed (4 messages).
B'Warn message' and 'Error message' are printed (2 messages).
COnly 'Error message' is printed (1 message).
D'Info', 'Warn', and 'Error' messages are printed (3 messages).
Attempts:
2 left
💡 Hint
More specific package settings override broader ones.

Practice

(1/5)
1. Which log level in Spring Boot shows the most detailed information, typically used for diagnosing problems during development?
easy
A. ERROR
B. INFO
C. WARN
D. TRACE

Solution

  1. Step 1: Understand log level hierarchy

    TRACE is the most detailed log level, showing fine-grained events.
  2. Step 2: Compare with other levels

    INFO, WARN, and ERROR show less detail and focus on general info or problems.
  3. Final Answer:

    TRACE -> Option D
  4. Quick Check:

    Most detailed log = TRACE [OK]
Hint: TRACE logs show the tiniest details for debugging [OK]
Common Mistakes:
  • Confusing INFO with TRACE as most detailed
  • Thinking ERROR shows all details
  • Assuming WARN is more detailed than DEBUG
2. Which of the following is the correct way to set the log level to WARN in application.properties for Spring Boot?
easy
A. logging.level.root=WARN
B. log.level=WARN
C. logging.level=WARN
D. logging.root.level=warn

Solution

  1. Step 1: Recall Spring Boot logging property format

    The correct property is logging.level.root to set root log level.
  2. Step 2: Check option syntax

    logging.level.root=WARN uses correct key and uppercase level, matching Spring Boot conventions.
  3. Final Answer:

    logging.level.root=WARN -> Option A
  4. Quick Check:

    Correct property key = logging.level.root [OK]
Hint: Use logging.level.root=LEVEL to set global log level [OK]
Common Mistakes:
  • Using log.level instead of logging.level.root
  • Incorrect property key like logging.root.level
  • Using lowercase level names incorrectly
3. Given this Spring Boot code snippet:
logger.debug("Debug message");
logger.info("Info message");
logger.error("Error message");

If the log level is set to INFO, which messages will appear in the logs?
medium
A. Info message, Error message
B. Only Error message
C. Debug message, Info message, Error message
D. Only Debug message

Solution

  1. Step 1: Understand log level filtering

    Setting level to INFO shows logs at INFO and higher severity (WARN, ERROR).
  2. Step 2: Check which messages qualify

    DEBUG is lower than INFO, so it is hidden; INFO and ERROR show.
  3. Final Answer:

    Info message, Error message -> Option A
  4. Quick Check:

    INFO level shows INFO and ERROR logs [OK]
Hint: Logs show messages at set level and above [OK]
Common Mistakes:
  • Assuming DEBUG logs show at INFO level
  • Thinking ERROR logs are hidden at INFO level
  • Confusing INFO with DEBUG level
4. You set logging.level.com.example=DEBUG in application.properties, but DEBUG messages from com.example.service do not appear. What is the most likely cause?
medium
A. DEBUG level is not supported in Spring Boot
B. The root log level is set higher than DEBUG, blocking DEBUG logs
C. The package name is misspelled in the property
D. You must restart the application to apply log level changes

Solution

  1. Step 1: Check property correctness

    If the package name is misspelled, the setting won't apply to the intended classes.
  2. Step 2: Evaluate other options

    DEBUG is supported; root level does not block specific package settings; restart is usually required but not the main cause.
  3. Final Answer:

    The package name is misspelled in the property -> Option C
  4. Quick Check:

    Correct package name is critical for log level settings [OK]
Hint: Check package spelling carefully in logging properties [OK]
Common Mistakes:
  • Assuming root level overrides package level always
  • Believing DEBUG is unsupported
  • Ignoring typos in package names
5. You want to see detailed logs only for the com.example.repository package but keep the rest of the application logging at WARN level. Which application.properties configuration achieves this?
hard
A. logging.level.root=TRACE logging.level.com.example.repository=WARN
B. logging.level.root=WARN logging.level.com.example.repository=TRACE
C. logging.level.root=INFO logging.level.com.example.repository=ERROR
D. logging.level.root=DEBUG logging.level.com.example.repository=INFO

Solution

  1. Step 1: Set global log level to WARN

    Set logging.level.root=WARN to limit logs globally to warnings and errors.
  2. Step 2: Override package log level to TRACE

    Set logging.level.com.example.repository=TRACE to get detailed logs only for that package.
  3. Final Answer:

    logging.level.root=WARN logging.level.com.example.repository=TRACE -> Option B
  4. Quick Check:

    Global WARN + package TRACE = detailed logs only there [OK]
Hint: Set root level high, override package level low for details [OK]
Common Mistakes:
  • Setting root level too low, flooding logs
  • Overriding package with higher level than root
  • Confusing package and root property keys
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard