Skip to content

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

Open
@zorba128

Description

@zorba128

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions