0

I just configured SeekToCurrentErrorHandler in spring cloud stream with kafka project and I see tons of logs (one stacktrace per each delivery attempt) which I would like to silence. Is it possible?

PS. I do not know if it is relevant (and whether I do it right. Comments are welcome ;)), but I am throwing an exception from my @StreamListener which is handled by @ServiceActivator and inside it I am rethrowing wrapped exception in order to run error handler.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
Piotr Tempes
  • 1,091
  • 1
  • 12
  • 26

1 Answers1

2

Starting with spring-kafka version 2.5 (comes with Boot 2.3) you can set the log level.

/**
 * Set the level at which the exception thrown by this handler is logged.
 * @param logLevel the level (default ERROR).
 */
public void setLogLevel(KafkaException.Level logLevel) {
    Assert.notNull(logLevel, "'logLevel' cannot be null");
    this.logLevel = logLevel;
}
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Luckily we are able to bump up the version. Works like a charm. Thanks a lot! – Piotr Tempes Mar 02 '21 at 21:23
  • @PiotrTempes I'm facing the same issue. Can you please share which version resolved the issue. I'm using spring kafka 2.6.11 and I was not able to suppress logging the stacktrace by changing the log level. – venky Nov 18 '21 at 17:45
  • Please ask a new question showing the code, config, and stack trace. – Gary Russell Nov 18 '21 at 18:03
  • @venky unfortunately I am no longer working on this project, I do not have access to it's codebase and it was quite some time ago so I do not remember from top of my head. I think you should do as Gary suggested above. Ask new question providing as much info as possible. The version you are using should be ok so I guess it is a configuration issue. Kafka comes with a lot of different abstractions in spring, so maybe in your case a different configuration kicks in? Hard to tell based on information you posted. Just dig a little bit deeper. I am sure you will get to it eventually. Good luck! – Piotr Tempes Nov 22 '21 at 07:48