[logback-user] Compression in SiftingAppender

TJ Rothwell tj.rothwell at gmail.com
Fri Nov 4 15:32:20 CET 2011


Hi,

I'm using SiftingAppender on top of an appender that uses compression. When
using a variable (like username) that will show up more than once, it works
great. But when using a session id which is unique, then the log file will
not be triggered for compression leading to larger disk usage. Is there a
way to go about triggering the file to be compressed when the
SiftingAppender closes the child appender after it's timeout period?

Definition of my appender:
  <appender name="SIFT-SESSION_ID"
class="ch.qos.logback.classic.sift.SiftingAppender">
    <discriminator
class="ch.qos.logback.classic.sift.MDCBasedDiscriminator">
      <key>SESSION_ID</key>
      <defaultValue>unknown</defaultValue>
    </discriminator>
    <sift>
      <appender name="FILE-${SESSION_ID}"
class="ch.qos.logback.core.rolling.RollingFileAppender">
        <encoder>
          <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS zz} %-5level [%thread]
%logger{35} - %msg%n%xEx{full}</pattern>
        </encoder>
        <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

<fileNamePattern>${CONTEXT_DATA_PATH}/logs/session/session-${SESSION_ID}.%d{yyyy-MM-dd}.%i.txt.zip</fileNamePattern>
          <timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>100MB</maxFileSize>
          </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
      </appender>
    </sift>
  </appender>

Thanks!
-- TJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20111104/6c75ba12/attachment.html>


More information about the Logback-user mailing list