Re: logging Exception toString with slf4j

2020-10-08 Thread Ralph Goers
One other option is to use the Log4j API and do logger.atWarn().log(“{}”, throwable); Since the LogBuilder adds exceptions using a separate method the log method knows it is a parameter to the format. FWIW, there is no disadvantage in switching to the Log4j API. It can be bridged to other logg

Re: logging Exception toString with slf4j

2020-10-08 Thread Ralph Goers
Yes, ultimately that ends up doing protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message, final Throwable t) { logMessageSafely(fqcn, level, marker, messageFactory.newMessage(message), t); } In AbstractLogger. As you can see the th

Re: logging Exception toString with slf4j

2020-10-08 Thread Bobby Bissett
On Thu, Oct 8, 2020 at 10:37 PM Clément Guillaume wrote: > > I guess I can do the following (not very elegant) > logger.warn("{} ", (Object)new Exception("my message")); > Or just log: new Exception("my message").toString(); Cheers, Bobby

Re: logging Exception toString with slf4j

2020-10-08 Thread Clément Guillaume
good call, while the other is calling public void warn(String format, Object arg1, Object arg2) I guess I can do the following (not very elegant) logger.warn("{} ", (Object)new Exception("my message")); On Thu, Oct 8, 2020 at 1:31 AM Anders wrote: > Hi, > > I think logger.warn("{} ", new Exc

Re: logging Exception toString with slf4j

2020-10-08 Thread Anders
Hi, I think logger.warn("{} ", new Exception("my message")); will call warn(java.lang.String,java.lang.Throwable) ). On Thu, Oct 8, 2020 at 7:46 AM Clément Guillaume wrote: > Hi, > > I'm using slf4j