I've updated my github with an implementation that works when the for my circumstance (compression & no file in appender).
* 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 didn't see a way to close the parent appender's outputstream from my RollingPolicy. I might have to subclass RollingFileAppender to make this solution production ready. I also noted a few other concerns I have in the comments--look for // FIXME's. -- TJ On Fri, Nov 4, 2011 at 7:06 AM, ceki <c...@qos.ch> wrote: > > 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<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<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 >> >> ______________________________**_________________ > Logback-user mailing list > Logback-user@qos.ch > http://mailman.qos.ch/mailman/**listinfo/logback-user<http://mailman.qos.ch/mailman/listinfo/logback-user> >
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user