AxonFramework
AxonFramework copied to clipboard
Deadletter Logging with Logback Classic
Hi
we noticed the following log statement when a message is deadlettered:
Adding dead letter with message id [ebb06fa9-4627-411e-a0de-31653caecf60] because [{}].
org.axonframework.messaging.deadletter.ThrowableCause: One or more JSR303 constraints were violated:
As you can see, the second parameter in the log statement is not handled as a regular parameter for the format string but rather as an exception.
This behavior is caused by the underlying logging implementation in our case Logback Classic, which detects the throwable paramter type and extacts it from the arguments to print it as a stack trace:
https://github.com/qos-ch/logback/blob/92e1a5ea0adc3bc215fc9441fb711fb5726974e4/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java#L161-L167
Depending on the intention of the log statement, a fix could be to use Exception#getSimpleName()
in these places:
https://github.com/AxonFramework/AxonFramework/blob/d7c6fcd7216558d9d90107e1ef77c0ae81530cb3/messaging/src/main/java/org/axonframework/messaging/deadletter/InMemorySequencedDeadLetterQueue.java#L116
https://github.com/AxonFramework/AxonFramework/blob/d7c6fcd7216558d9d90107e1ef77c0ae81530cb3/messaging/src/main/java/org/axonframework/eventhandling/deadletter/jdbc/JdbcSequencedDeadLetterQueue.java#L205-L206
etc.