Bird
0
0

Given the following code snippet in a Spring Boot class:

medium📝 component behavior Q13 of 15
Spring Boot - Logging
Given the following code snippet in a Spring Boot class:
private static final Logger logger = LoggerFactory.getLogger(App.class);

public void run() {
    logger.info("Start running");
    logger.debug("Debugging info");
    logger.error("An error occurred");
}

What will be the visible output if the logging level is set to INFO?
AAll three messages will be logged
BNo messages will be logged
COnly "Debugging info" will be logged
DOnly "Start running" and "An error occurred" messages will be logged
Step-by-Step Solution
Solution:
  1. Step 1: Understand logging levels and filtering

    Logging levels filter messages: INFO level shows INFO, WARN, ERROR but hides DEBUG messages.
  2. Step 2: Apply level filter to messages

    "Start running" is INFO, "Debugging info" is DEBUG (hidden), "An error occurred" is ERROR (shown).
  3. Final Answer:

    Only "Start running" and "An error occurred" messages will be logged -> Option D
  4. Quick Check:

    INFO level hides DEBUG but shows INFO and ERROR [OK]
Quick Trick: INFO level shows INFO and above, hides DEBUG [OK]
Common Mistakes:
  • Assuming DEBUG messages show at INFO level
  • Thinking ERROR messages are hidden
  • Confusing log levels order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes