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

JBoss Logging throws NullPointerException when used with Log4j 2.0 final.

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • None
    • 3.2.0.Beta1
    • jboss-logging-log4j
    • None
    • Compatibility/Configuration, User Experience

      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:
      50

      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.

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

              Created:
              Updated:
              Resolved: