logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clément Guillaume <cguilla...@hotpads.com>
Subject logging Exception toString with slf4j
Date Wed, 07 Oct 2020 23:46:15 GMT
Hi,

I'm using slf4j (1.7.25) and log4j (2.13.3).
My config is simple, just a console appender.
I'm trying to log the toString of an Exception with a parameterized message.
It works fine when there is more than one parameter, but when it's a single
one, the whole exception stacktrace is printed.

org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("loggerName");
> logger.warn("{} {} ", "an error occured", new Exception("my message")); //
> work as expected: print only the toString
> logger.warn("{} ", new Exception("my message")); // print the curly
> brackets and the whole stacktrace


an error occured java.lang.Exception: my message
> {}
> java.lang.Exception: my message
> at com.example.Main.main(Main.java:206) [test-classes/:?]
>

I wanted to confirm this is a bug and wanted to know if it's more likely
caused by slf4j or log4j?

Thank you.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message