Uploaded image for project: 'JBoss Logging'
  1. JBoss Logging
  2. JBLOGGING-85

slf4j-jboss-logmanager does not support parametization of a logging statement in the presence of a Throwable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • slf4j-jboss-logmanager
    • None
    • Hide

      Run the following code inside JBoss-6.1.0.Final, after upgrading jcl-over-slf4j.jar and slf4j-api.jar to 1.6.1.

      try {
      throw new RuntimeException("bla bla");
      } catch (RuntimeException e) {
      logger.error("Text: {}", "mytext", e);
      }

      No stacktrace is printed, not even e.getMessage(). It is completely ignored.

      Show
      Run the following code inside JBoss-6.1.0.Final, after upgrading jcl-over-slf4j.jar and slf4j-api.jar to 1.6.1. try { throw new RuntimeException("bla bla"); } catch (RuntimeException e) { logger.error("Text: {}", "mytext", e); } No stacktrace is printed, not even e.getMessage(). It is completely ignored.

      http://www.slf4j.org/faq.html#paramException describes that from slf4j 1.6 onwards doing the following will print a stacktrace:

      logger.error("Failed to format {}", s, e);

      However, due to the implementation of org.slf4j.impl.MessageFormatter in slf4j-jboss-logmanager, when logger.error(String, Object, Object) is called, even if the third parameter is a Throwable, it is not recognised as such.

      Investigating further, it seems that org.slf4j.impl.MessageFormatter is probably just an old copy of org.slf4j.helpers.MessageFormatter in slfj-api 1.6.1, where most formatting methods used to return a String now returns a FormattingTuple.

      This issue can be fixed by making all calls in Slf4Logger to org.slf4j.impl.MessageFormatter to call org.slf4j.helpers.MessageFormatter instead and appropriately call ExtLogRecord.setThrown(formattingTuple.getThrowable()).

            jperkins-rhn James Perkins
            herculeszeus_jira Hercules Zeus (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: