Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
None
Description
When a logging statement occurs using an extending class, in my case, XLogger, with a parameterized query, on a LocationAwareLogger, the LoggerWrapper will use the MessageFormatter, format the message, and then pass it onto the bounded logger with null as the throwable. The MessageFormatter has already identified the exception, if applicable, and parsed it out of the object list. It has also generated an object list for the remaining objects. In my case, the underlying logged, log4j12, simply ignored the object list, used the formatted string, and saw null for the exception.
Attached is a very simple example (with pom and log4j.properties file) to demonstrate the problem.
LoggerWrapperFailureDemo.java
package demo.slf4j.ext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.ext.XLogger; public class LoggerWrapperFailureDemo { static XLogger logger = new XLogger(LoggerFactory.getLogger(LoggerWrapperFailureDemo.class)); static Logger traditional = LoggerFactory.getLogger(LoggerWrapperFailureDemo.class); public static void main( String[] args ) { Exception e = new Exception("foo", new Exception("bar")); logger.warn( "No Param", e); logger.warn( "Param: {}", "etc", e); traditional.warn( "No XLogger (So No LoggerWrapper {} ", "etc", e); } }