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

EncodingPatternConverter CRLF encoding is slow with large log messages (it has quadratic time complexity)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.14.1
    • 2.15.0
    • Pattern Converters
    • None

    Description

      This code that escapes newlines is very slow on large log messages where those message contain lots of newline characters. For example "abc" repeated a million times takes less than a second to log, but "a\r\n" repeated a million times takes over 5 minutes (in my test).

      I think it is accurate to say that this code has quadratic time complexity: https://github.com/apache/logging-log4j2/blame/master/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/EncodingPatternConverter.java#L151

      If necessary I can supply more examples and/or a fix.

      Attachments

        Issue Links

          Activity

            People

              vy Volkan Yazici
              garethdanielsmith Gareth Daniel Smith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: