[logback-user] Compression in SiftingAppender

ceki ceki at qos.ch
Fri Nov 4 13:06:50 CET 2011


I don't think rollover() should be invoked within the close() method. 
You rather want to close the file and than compress it.

The compression goes something like:

   if (compressionMode == CompressionMode.NONE) {
      // nothing to do?
   } else {
     if (getParentsRawFileProperty() == null) {
       asyncCompress(elapsedPeriodsFileName, elapsedPeriodsFileName,
                     elpasedPeriodStem);
     } else {
       renamedRawAndAsyncCompress(elapsedPeriodsFileName,
                                  elpasedPeriodStem);
     }
   }

See the rollover() method in TimeBasedRollingPolicy. I'll have another 
look at all this tomorrow.

Cheers,

-- 
Ceki
http://twitter.com/#!/ceki

On 05/11/2011 12:30 AM, TJ Rothwell wrote:
> Ceki,
>
> So I gave it a shot.
>
>   * CloseTBRP.java
>     <https://github.com/trothwell/logback-test/blob/master/src/main/java/org/trothwell/lbtest/CloseTBRP.java>
>   * TestCloseTBRP.java
>     <https://github.com/trothwell/logback-test/blob/master/src/test/java/org/trothwell/lbtest/TestCloseTBRP.java>
>
> 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
>


More information about the Logback-user mailing list