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

JBoss Logging throws NullPointerException when used with Log4j 2.0 final.

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Done
    • Blocker
    • 3.2.0.Final
    • 3.2.0.Beta1
    • jboss-logging-log4j
    • None

    Description

      When you enable logging of org.hibernate.SQL the log is not send to the log4j loggers/appenders.
      The reason for that is a null pointer exception in:
      Class:
      Log4j2Logger
      Method:
      protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
      Line:
      54

      Log4j2Logger.java
          @Override
          protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
              final org.apache.logging.log4j.Level translatedLevel = Log4j2Logger.translate(level);
              if (this.logger.isEnabled(translatedLevel)) {
                  try {
                      this.logger.log(null, loggerClassName, translatedLevel,
                              parameters == null || parameters.length == 0 ? this.messageFactory.newMessage(message) :
                                      this.messageFactory.newMessage(String.valueOf(message), parameters),
                              thrown);
                  } catch (Throwable ignored) { }
              }
          }
      

      This this.logger.log call is the one causing NPE which is ignored .. because of the surrounding catch.

      If you change the call to something like :

      Example (params are not passed but you can pas them as well )
      this.logger.log(translatedLevel,this.messageFactory.newMessage(String.valueOf(message), thrown)
      

      As an example you will see its working.

      Attachments

        Issue Links

          Activity

            People

              jperkins-rhn James Perkins
              gochev Nayden Gochev (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: