Class LogAggregator
The aggregation can be based on time or on count.
Messages known to be generated for an event occurring very frequently, for every protocol message or periodically, can be logged at first occurrence and then only at increasing intervals (if based on time), or only after a number of occurrences (if based on count).
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
countBasedLog
(LocalizedLogger logger, LocalizableMessage message) Start the aggregation for a message that will be logged based on count and only after 2 occurrences.void
log
(Consumer<LocalizableMessage> logMethod, LocalizableMessage message) Log a message and start the aggregation for it.void
Purge expired messages and log message bursts if any.
-
Constructor Details
-
LogAggregator
public LogAggregator()
-
-
Method Details
-
log
Log a message and start the aggregation for it.The message will be logged right away and if repeated, at fixed intervals. In case of burst (more than 20 times in a second), there will be a warning about it.
- Parameters:
logMethod
- how to log the messagemessage
- the message
-
countBasedLog
Start the aggregation for a message that will be logged based on count and only after 2 occurrences.The message will be logged once as WARNING after 2 occurrences and once as ERROR after 5 occurrences. After that it will be logged at fixed intervals. In case of burst (more than 20 times in a second), there will be a warning about it.
This behavior is suited for connections errors.
- Parameters:
logger
- logger to use for the messagemessage
- the message
-
purgeAndLogMessageBursts
public void purgeAndLogMessageBursts()Purge expired messages and log message bursts if any.
-