Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1205

CheckForCollisions methods can cause performance issue

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 1.5.7
    • 1.1.7
    • logback-core
    • None

    Description

      We relies on SiftingAppender heavily to put log messages into different log files. And as our application keeps running, it creates large number of log files, around 14 new log files per second. Here's part of our logback.xml

        <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
          <timeout>1 minute</timeout>
          <discriminator>
            <key>logging-context</key>
            <defaultValue>NO-CONTEXT</defaultValue>
          </discriminator>
          <sift>
            <appender name="ROLLING-${logging-context}" class="ch.qos.logback.core.rolling.RollingFileAppender">
              <file>logs/${logging-context}/log.log</file>
              <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <!-- daily rollover -->
                <fileNamePattern>logs/${logging-context}/log.%d{yyyy-MM-dd}.log</fileNamePattern>
              </rollingPolicy>
              <encoder>
                <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
              </encoder>
            </appender>
          </sift>
        </appender>
      

      The problem is that RollingFileAppender keeps all log files names in a map in the context, for the purpose of checking file name collision. Our application becomes very slow after running for 2 or 3 hours, because the file names map grows very big, and every time before new log file is created the appender is going to iterate all existing files names to check collision.

      Note that the FileAppender also has the same problem.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            jason.h Jason Huang
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: