Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message formatting (interpolation) with last argument of Throwable #426

Open
zorba128 opened this issue Jan 26, 2024 · 0 comments
Open

Message formatting (interpolation) with last argument of Throwable #426

zorba128 opened this issue Jan 26, 2024 · 0 comments

Comments

@zorba128
Copy link

zorba128 commented Jan 26, 2024

slf4j interprets last message formatting argument as exception to be attached to log entry.
Even if message format string has placeholder for it - producing message with empty placeholder, and unwanted stacktrace.

val ex = new RuntimeException("XXX")
val item = Item(123)

log.warn(s"Processing issue; ex=$ex, item=$item")   // this works fine
log.warn(s"Processing issue; item=$item, ex=$ex)   // and this produces "... item=Item(123), ex={}"  followed by stacktrace

See slf4j issue

I think it should be fixed upstream, but maybe we could apply some simple workaround for now - such as appending "null" to formatting args if no exception is provided explicitly.

m.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants