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 logging implementations just like SLF4J can. Plus Log4j is actively 
maintained whereas SLF4J hasn’t had any activity in over a year.

Ralph

> On Oct 8, 2020, at 9:06 PM, Bobby Bissett <robert.biss...@enterprisedb.com> 
> wrote:
> 
> On Thu, Oct 8, 2020 at 10:37 PM Clément Guillaume <cguilla...@hotpads.com>
> 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



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to