You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2012/09/25 01:44:13 UTC

org.apache.logging.log4j.Logger.error(Object, Throwable)

The case for changing org.apache.logging.log4j.Logger.error(Object,
Throwable) to error(Object, Throwable...), note the "...".

The idea here is to deal with:

try {
   // something
} catch (CantDoItEx1 cantDoItEx) {
   // something else to rectify the situation, like a clean up
   try {
      // clean it up
   } catch (CleanupEx cleanupEx) {
      logger.log("could not clean up", cleanupEx, cantDoItEx);
   }
}

Thoughts?

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: org.apache.logging.log4j.Logger.error(Object, Throwable)

Posted by Ralph Goers <ra...@dslextreme.com>.
Before I have thoughts I'd have to know what you would expect to be printed. Two stack traces? They aren't strictly chained. 

But isn't this a case where a suppressed exception would really be used (Java 7)?  Log4j 2 already supports that via ThrowableProxy's getSuppressedStackTrace method.

Ralph

On Sep 24, 2012, at 4:44 PM, Gary Gregory wrote:

> The case for changing org.apache.logging.log4j.Logger.error(Object, Throwable) to error(Object, Throwable...), note the "...".
> 
> The idea here is to deal with:
> 
> try {
>    // something
> } catch (CantDoItEx1 cantDoItEx) {
>    // something else to rectify the situation, like a clean up
>    try {
>       // clean it up
>    } catch (CleanupEx cleanupEx) {
>       logger.log("could not clean up", cleanupEx, cantDoItEx); 
>    }
> }
> 
> Thoughts?
> 
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
> Spring Batch in Action: http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory