Bird
0
0

What will happen if you try to create a logger in a Spring Boot class using this code?

medium📝 Debug Q5 of 15
Spring Boot - Logging
What will happen if you try to create a logger in a Spring Boot class using this code?
private static Logger logger = LoggerFactory.getLogger();
ACompilation error due to missing class argument
BLogger created successfully with default class
CRuntime error when logger is used
DLogger created but logs go to console only
Step-by-Step Solution
Solution:
  1. Step 1: Check LoggerFactory.getLogger method signature

    getLogger requires a Class or String argument to identify the logger name.
  2. Step 2: Analyze code missing argument

    Calling getLogger() without arguments causes a compilation error.
  3. Final Answer:

    Compilation error due to missing class argument -> Option A
  4. Quick Check:

    LoggerFactory.getLogger requires argument [OK]
Quick Trick: Always pass class or name to LoggerFactory.getLogger() [OK]
Common Mistakes:
  • Omitting argument to getLogger()
  • Assuming default logger is created without argument
  • Confusing compile and runtime errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes