Tuesday, 20 August 2013

Will fillInStackTrace() is more cheaper when use in log4j?

Will fillInStackTrace() is more cheaper when use in log4j?

I'm using log4j in my application, just curious to know if I'm passing in
an Exception object into logger, as in (1), will this consume more
resource than if I pass in e.fillInStackTrace(), as in (2)? In other
words, will (2) is more cheaper than (1)? Below is my sample code on
log4j.
private static Logger logger = Logger.getLogger(...);
try {
...
}
catch( Exception e ) {
logger.error("blah blah blah", e); // (1)
logger.error("blah blah blah", e.fillInStackTrace()); // (2)
}
I am a bit confuse here, please help clarify?

No comments:

Post a Comment