Details
-
Bug
-
Resolution: Unresolved
-
Major
-
1.1.7
-
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.