jhannes / logevents

An easy-to-extend implementation of SLF4J with batteries included and sensible defaults
Other
42 stars 8 forks source link

High-water-mark batching of messages #6

Open jhannes opened 5 years ago

jhannes commented 5 years ago

Batch up messages in a context and process all only if at least one was over a given threshold. This is useful to get the full context of an error situation.

This can probably be implemented with MDC.put and MDC.remove acting as the boundaries.

Possible configuration syntax:

observer.fooObserver=BatchingLogEventObserver
observer.fooObserver.mdcKey=FOO
observer.fooObserver.reportThreshold=ERROR
observer.fooObserver.includeThreshold=INFO
observer.fooObserver.batchProcessor=SlackLogEventBatchProcessor

(Suggested by Axel Fontaine)

jhannes commented 5 years ago

In order to avoid spam to high-intrusion channels (Slack, Email), this must be possible to combine with the cooldownTime. But that means that there is a risk that more MDC-batches will be included in the same report. (For example if a client spams with requests that cause errors) The events must probably be grouped somehow on the mdcKey.

jhannes commented 3 years ago

It would be nice to set loglevel on a logger based on mdc values. E.g.

logger.org.foo.bar=INFO,TRACE@mdc:user=testing console