[logback-dev] Batching logs

Durchholz, Joachim Joachim.Durchholz at hennig-fahrzeugteile.de
Fri Oct 18 11:39:54 CEST 2013


I've been trying to find a viable way to do this, but no luck.

Use cases for batching:
1) A fallback appender that runs out of options. (Say, the machine can only talk to network connections to report errors, and the network is down for a while.)
2) An SMTP appender that collects a chunk of messages before sending them out, to avoid spamming the recipient with a separate mail message per log entry.

This isn't too hard to do actually, but one aspect got me stumped: Application termination.
Not that it's hard to add a termination hook and task it with sending the logs.
However, how do I make sure that logs generated by other termination hooks get sent? I found no way to make sure that the terminatin hook thread stays alive until all other threads that use logging have terminated.


More information about the logback-dev mailing list