Hi, I think logger.warn("{} ", new Exception("my message")); will call warn(java.lang.String,java.lang.Throwable) <http://www.slf4j.org/apidocs/org/slf4j/Logger.html#warn(java.lang.String,java.lang.Throwable> ).
On Thu, Oct 8, 2020 at 7:46 AM Clément Guillaume <cguilla...@hotpads.com> wrote: > 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. >