Bird
0
0

Which annotation can be used in a Spring Boot class to automatically create a logger instance?

easy📝 Conceptual Q2 of 15
Spring Boot - Logging
Which annotation can be used in a Spring Boot class to automatically create a logger instance?
A@Log
B@Slf4j
C@Logger
D@Loggable
Step-by-Step Solution
Solution:
  1. Step 1: Recognize Lombok annotations for logging

    Lombok provides @Slf4j to automatically generate a logger field in the class.
  2. Step 2: Confirm correct annotation name

    @Slf4j is the exact Lombok annotation for SLF4J logger creation.
  3. Final Answer:

    @Slf4j -> Option B
  4. Quick Check:

    Lombok logger annotation = @Slf4j [OK]
Quick Trick: Use @Slf4j to auto-generate SLF4J logger [OK]
Common Mistakes:
  • Using @Logger which does not exist
  • Confusing @Log with @Slf4j (different logging frameworks)
  • Assuming @Loggable is a valid Lombok annotation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes