Changing KafkaBackOffException Logging Level

如果重试主题中的消息不适合使用,将引发 KafkaBackOffException。默认情况下会以 DEBUG 级别记录此类异常,但您可以在 @Configuration 类中的 ListenerContainerFactoryConfigurer 中设置错误处理自定义器来更改此行为。

When a message in the retry topic is not due for consumption, a KafkaBackOffException is thrown. Such exceptions are logged by default at DEBUG level, but you can change this behavior by setting an error handler customizer in the ListenerContainerFactoryConfigurer in a @Configuration class.

例如,若要将日志记录级别更改为 WARN,您可能需要添加:

For example, to change the logging level to WARN you might add:

@Override
protected void configureCustomizers(CustomizersConfigurer customizersConfigurer) {
    customizersConfigurer.customizeErrorHandler(defaultErrorHandler ->
            defaultErrorHandler.setLogLevel(KafkaException.Level.WARN))
}