-
Notifications
You must be signed in to change notification settings - Fork 1.4k
WhenRepeated Filter
Rolf Kristensen edited this page Jun 16, 2022
·
13 revisions
Matches when the calculated layout has already been logged. Useful if having an aggressive logger, and wants to throttle the output.
Introduced with NLog ver. 4.5
<rules>
<logger ... >
<filters defaultAction="Log">
<whenRepeated layout="Layout" timeoutSeconds="30" action="Ignore" />
</filters>
</logger>
</rules>
Can also be combined with FilteringWrapper-target.
- layout - Layout to be used to filter log messages. Layout Required.
- timeoutSeconds - How long to ignore identical messages before logging again (Default 10 secs)
-
action - Action to be taken when filter matches. Required.
Possible values:- Ignore - The message should not be logged.
- IgnoreFinal - The message should not be logged and processing should be finished.
- Log - The message should be logged.
- LogFinal - The message should be logged and processing should be finished.
- Neutral - The filter doesn't want to decide whether to log or discard the message.
- includeFirst - Should action also be applied to the initial logevent? When enabled then it will only perform the first logging if the messages continues after the initial timeout. (Default: false)
- FilterCountPropertyName - Tell how many identical log messages has been ignored. By adding LogEvent-Property with this name to the next LogEvent after timeout expires.
- FilterCountMessageAppendFormat - Tell how many identical log messages has been ignored. By appending to LogEVent-Message to the next LogEvent after timeout expires (Ex. " (Hits: {0}")
- MaxLength - Max number of characters to include when checking for identical messages (Default 1000 characters)
- MaxFilterCacheSize - Max number of unique log messages to keep in cache, before starting to prune (Default 50000)
- DefaultFilterCacheSize - Initial start size of the cache for keep track of unique log messages (Default 1000)
- OptimizeBufferDefaultLength - Initial allocated size of the reusable buffers (Default 1000)
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json