Ceki,

So I gave it a shot.
I'm running into a few problems if you have some time to take a look:
  • I'm unable to delete files after stopping LoggerContext.
  • Output file count is off (SiftingAppender or RollingFileAppender doesn't create both output files)
  • NullPointerException occurs when stopping LoggerContext with CloseTBRP in use
I have two scenarios.
  1. Create a normal TimeBasedRollingPolicy configured for compression that will create 2 output files.
  2. Create the new auto-close CloseTBRP that will do the same.

For both configurations this is the steps: (or look at unit test)
  1. Create new LoggerContext
  2. Configure LoggerContext
  3. Submit a log event
  4. Set MDC property for discriminator
  5. Submit a log event
  6. Stop LoggerContext
  7. Check log file counts
    1. for TBRP, 2 text files
    2. for CloseTBRP, 2 zip files

Have a great weekend,
-- TJ

On Fri, Nov 4, 2011 at 9:59 AM, ceki <ceki@qos.ch> wrote:
Hi TJ,

It's a problem which has not been considered previously. Nice problem
description btw. One solution would be to subclass
TimeBasedRollingPolicy and override the stop() method so that it
compresses the current log file. It should not be too hard to do. Ask
for help if you run into trouble.


On 04/11/2011 3:32 PM, TJ Rothwell wrote:
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


--
Ceki
http://twitter.com/#!/ceki
_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user