SuppressionEnabled Property
Gets or sets whether log suppression is enabled for this logger.
Definition
Namespace: GHost.Core.Logging
Type: ILogger
Assembly: GHost.Core.dll
bool SuppressionEnabled { get; set; }
Property Value
bool
true to enable log suppression; otherwise, false.
Remarks
Log suppression is a feature that allows the logger to suppress similar log entries after certain conditions. This can help reduce log noise and improve performance by preventing excessive logging of repetitive messages.
When this property is set to true, the logger will track log entries others that are similar. Once the SuppressionThreshold has been exceeded, the logger will cease to log similar entries until the ResetSuppression method is called.
The specifics of what constitutes "similar" entries and how suppression is applied is determined by the logger's SuppressionMode and the minimum log level for suppression defined by SuppressionMinimumLevel.
When this property is set to false, the logger will not perform any suppression and will log all entries as they are received, regardless of their similarity or frequency.
When this property is set to true, suppression tracking is reset and the count of all tracked logs for this logger is set to 0, regardless of what the tracked count was previously.
Example
ILogger log = GetLoggerFromSomewhere();
log.SuppressionEnabled = true;
log.SuppressionMode = LogSuppressionMode.CodeAndLevel;
log.SuppressionThreshold = 3;
log.Info("code1", "A repetitive log message"); // 1st - Will be logged
log.Info("code1", "A repetitive log message"); // 2nd - Will be logged
log.Info("code1", "A repetitive log message"); // 3rd - Will be logged
log.Info("code1", "A repetitive log message"); // 4th - Will be suppressed
log.Info("code2", "A repetitive log message"); // 1st - Will be logged (different code)
log.Warn("code1", "A repetitive log message"); // 1st - Will be logged (different level)
log.Info("code1", "A repetitive log message"); // 5th - Will be suppressed (original code)
log.ResetSuppression(); // Clear all tracked logs
log.Info("code1", "A repetitive log message"); // Will be logged again after reset