Spring Boot

Logging with SLF4J & Logback

Logging with SLF4J and Logback, log levels, configuration, appenders, patterns, package-level logging

20 면접 질문·
Junior
1

What is SLF4J in the Java ecosystem?

답변

SLF4J (Simple Logging Facade for Java) is an abstraction facade for various Java logging frameworks (Logback, Log4j, JUL). It allows decoupling application code from the concrete logging implementation, making it easy to change frameworks without modifying business code. Spring Boot uses SLF4J with Logback as the default implementation.

2

What is the default logging implementation in Spring Boot?

답변

Logback is the default logging implementation in Spring Boot. Developed by the creator of Log4j, Logback offers better performance, more flexible configuration, and native SLF4J compatibility. Spring Boot includes it automatically via spring-boot-starter-logging which is a transitive dependency of all web starters.

3

How to create a Logger instance with SLF4J in a Spring class?

답변

The recommended method is LoggerFactory.getLogger(ClassName.class) which creates a logger based on the fully qualified class name. This enables a consistent logger hierarchy with Java packages and simplifies configuration by package. Alternatively, Lombok provides @Slf4j which automatically generates the logger.

4

What are the standard log levels in SLF4J, from most verbose to most critical?

5

Which Spring Boot property sets the log level for a specific package?

+17 면접 질문

다음 면접을 위해 Spring Boot을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기