I learn a new thing today.
I knew that slf4j had two logger methods
org.slf4j.Logger.error(String, Object[])
org.slf4j.Logger.error(String, Throwable)
now If i wanted to call
logger.error("This is {} message {}", "test" ,"to kp" ,e);
then I was under the impression that it would not print the stack trace as it would use the signature with object array.
But I was wrong :). It seems log4j has a nice trick and it would print the trace if the last argument is an exception object, a fellow programmer told me this that slf4j already handles this http://www.slf4j.org/faq.html#paramException .
I knew that slf4j had two logger methods
org.slf4j.Logger.error(String, Object[])
org.slf4j.Logger.error(String, Throwable)
now If i wanted to call
logger.error("This is {} message {}", "test" ,"to kp" ,e);
then I was under the impression that it would not print the stack trace as it would use the signature with object array.
But I was wrong :). It seems log4j has a nice trick and it would print the trace if the last argument is an exception object, a fellow programmer told me this that slf4j already handles this http://www.slf4j.org/faq.html#paramException .
Comments
Post a Comment