[logback-user] Force FileAppender embedded in SiftingAppender to stop

Dario Campagna campagna at esteco.com
Tue Apr 24 17:34:23 CEST 2012


Hi,

   In an application I am developing I am using a SiftingAppender
embedding a FileAppender, defined within a logback configuration file.
Each FileAppender manages the logging events generated by a particular
process. Each process knows nothing (and should know nothing) about
the appenders managing its logging event.

I read in the documentation that an appender created by
SiftingAppender is automatically closed and discarded if unused for 30
minutes. I would like to stop the FileAppender associated to a process
as soon as the process ends its executions, this in order to close the
associated file and to avoid having a lot of opened streams.

The solution I came up with consists in defining a custom FileAppender
(to be embedded in the SiftingAppender) that stops itself upon
receiving a logging event  with a particular marker, e.g., STOP.

What do you think of this solutions? Are there any other (maybe
better) possible solutions I should consider?


Cheers,
Dario


More information about the Logback-user mailing list