Nice catch! I just saw this happen at work, I agree we should do something 
about it. 

One solution would be to modify ObjectMessage.getFormattedString():
If the object is an instance of Throwable then return the Throwable's 
stacktrace instead of its toString() result. 

I'm not a big fan of using instanceof, but it gives us a very compact solution. 

Thoughts?

Sent from my iPhone

> On 2015/02/28, at 8:33, Gary Gregory <[email protected]> wrote:
> 
> Hi All:
> 
> I was just surprised (in a bad) way that calling:
> 
> logger.trace(Throwable) compiles to the Object version of the API since we do 
> not have a Throwable API.
> 
> This means I am forced to do:
> 
> logger.trace("Cause:", throwable);
> 
> in order to see the stack trace.
> 
> Thoughts on adding trace(Throwable)? (As well as the other levels)
> 
> Gary
> 
> -- 
> E-Mail: [email protected] | [email protected] 
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

Reply via email to