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

logging hang when PatternLayout's pattern has miss pattern

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.2
    • Component/s: Configurators
    • Labels:
      None
    • Environment:

      windows 8.1 64bit
      java 1.7.0_55 64bit
      log4j2 2.0

      Description

      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration status="WARN">
        <Appenders>
          <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
          </Console>
        </Appenders>
        <Loggers>
          <Logger name="com.foo.Bar" level="trace" additivity="false">
            <AppenderRef ref="Console"/>
          </Logger>
          <Root level="error">
            <AppenderRef ref="Console"/>
          </Root>
        </Loggers>
      </Configuration>
      

      The above configuration syntax is correct. However, if one makes a mistake and instead writes:

      <PatternLayout pattern="%d\{HH:mm:ss.SSS  [%t] %-5level %logger\{36\} - %msg%n"/>
      

      Note the ommited character "}" in the date pattern.

      Run sample application.
      This will hang log4j2 logging system.

      sample source code:

      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;
       
      public class HelloWorld {
          private static Logger logger = LogManager.getLogger("HelloWorld");
          public static void main(String[] args) {
              logger.info("Hello, World!");
          }
      }
      

      appear pattern configuration error or logging print miss pattern.

        Attachments

          Activity

            People

            • Assignee:
              remkop@yahoo.com Remko Popma
              Reporter:
              moonumi moonumi
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: