TIL
2024.02.23 DLT logging custom
Gisungcu
2024. 2. 23. 23:43
DLT에 메시지가 도착하면 스택 트레이스를 로깅함.
에러 레벨로 로그를 남기고 있음. DLT 핸들러 메소드에서 자체적으로 남기도록 코드를 만들었기 때문에 스택 트레이스를 볼 필요가 없다고 생각했음.
해당 기능은 스프링 카프카에서 제공해주기 때문에 커스텀해서 사용하면 됨
@Configuration
class CustomRetryTopicConfiguration : RetryTopicConfigurationSupport() {
// Configuring the Dead Letter Publishing Recoverer Factory to never log listener exceptions.
// Because logging is performed in the DLT method.
override fun configureDeadLetterPublishingContainerFactory(): Consumer<DeadLetterPublishingRecovererFactory> {
return Consumer { dlprf: DeadLetterPublishingRecovererFactory -> dlprf.neverLogListenerException() }
}
}
RetryTopicConfigurationSupport (Spring for Apache Kafka 3.1.2 API)
Configure customizers for components instantiated by the retry topics feature.
docs.spring.io