There may be situations where in you only want to log the call stack (to find out how a method got invoked). An easy way to do this is to throw a new java.lang.Exception(“”). Catch it and log it in the log file. This way you can have the call stack for a method invocation without having the bebug.
try
{
throw new java.lang.Exception("Dummy exception to display call stack");
} catch (java.lang.Exception e)
{
log.debug("stack trace", e); // This will print the exception on to the log file
}
No comments:
Post a Comment