Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-49

double message formatting w/SLF4JLogger

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • API
    • None

    Description

      SLF4JLogger implements LocationAwareLogger which has

      public void log(Marker marker, String fqcn, int level, String message, Object[] argArray, Throwable t);

      Callers of this method format the message in advance. But SLF4JLogger also performs formatting.

      Example:

      slf4jLogger.info("slf4jLogger {}", "is formated twice? <{}>"); // works
      slf4jXlogger.info("slf4jXLogger {}", "is formated twice? <{}>"); // fails

      log4j2Logger.info("log4j2Logger shouldn't format <{}>"); // works
      jclOverSlf4jLogger.info("jclOverSlf4jLogger shouldn't format <{}>"); // fails

      Output:

      INFO Log4j2Testing [main] slf4jLogger is formated twice? <{}>
      INFO Log4j2Testing [main] slf4jXLogger is formated twice? <[[is formated twice? <{}>], null]>
      INFO Log4j2Testing [main] log4j2Logger shouldn't format <{}>
      INFO Log4j2Testing [main] jclOverSlf4jLogger shouldn't format <[null, null]>

      Attachments

        Activity

          People

            rgoers Ralph Goers
            jvasileff John Vasileff
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: