I'd like to log some messages only once while the program is running or be able to "unlock" the "unique" message so that it would be logged again.
Of course this can be done on code keeping track of the "unique" message and calling the log method only once, but I wonder if it is possible to do so with some configuration trick.
In pseudo code:
DO
i = i++
log.info("this should be unique")
log.info("this can be repeated")
LOOP WHILE i < 10
unlock("this should be unique")
log.info("this should be unique")
log.info("this can be repeated")
After that I should see "this should be unique" 2 times on my log.
Your other question made me consider this one also. It should be possible to create a system to log any message only once (before reset) by using any buffering appender and a custom
ITriggeringEventEvaluator
.Set the buffer size to 0 and the Evaluator to the custom one. In the custom Evaluator, keep track of all messages that went through the
IsTriggeringEvent
method and filter out the ones that have already been processed.It is possible to configure the messages that would be filtered, however you want to do it (config file, DB, etc), and how they can be logged again (timeout of filtering, explicit reset, etc) through the evaluator code.