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

SimpleLogger throws ArrayIndexOutOfBoundsException for an empty array

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.1
    • Component/s: API
    • Labels:

      Description

      There seems to be an issue with SimpleLogger implementation provided by log4j2. The issue seems to be in the new improved API supporting placeholders and var args when called with an Object Array of size 0.

      for e.g logger.error("Hello World {} in {} " , new Object[0]);

      A statement above results in an error as shown below

      ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
      at org.apache.logging.log4j.simple.SimpleLogger.logMessage(SimpleLogger.java:157)
      at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:1347)
      at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1312)
      at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:539)
      at TestError.main(TestError.java:21)

      Solution to place a check in SimpleLogger for checking the size of the array .

        Attachments

          Activity

            People

            • Assignee:
              garydgregory Gary Gregory
              Reporter:
              yogu13 Yogesh Rao
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: