Class LoggingIntervalPolicy
Represents a interval policy that controls the frequency of log message generation. This policy can be used to prevent log spam by limiting when identical log messages are written.
public sealed class LoggingIntervalPolicy
- Inheritance
-
objectLoggingIntervalPolicy
- Extension Methods
Properties
Identifier
Gets the unique identifier for this policy used for distinguishing logged events.
public string Identifier { get; }
Property Value
- string
Period
Gets the period for OncePerPeriod policy.
public TimeSpan Period { get; }
Property Value
- TimeSpan
Type
Gets the type of logging policy.
public LoggingPolicyEnum Type { get; }
Property Value
Methods
Default()
Creates a default logging policy that allows all logging.
public static LoggingIntervalPolicy Default()
Returns
- LoggingIntervalPolicy
Created logging policy configured for Default policy.
OncePerPeriod(string, TimeSpan)
Creates a logging policy that allows logging once per specified period.
public static LoggingIntervalPolicy OncePerPeriod(string identifier, TimeSpan period)
Parameters
identifierstringUnique identifier for distinguishing logged events. Based on this identifier, the system will be able to determine if the event has already been logged.
periodTimeSpanTime period after which logging is allowed again.
Returns
- LoggingIntervalPolicy
Created logging policy configured for OncePerPeriod policy.
OnlyOnce(string)
Creates a logging policy that allows logging only once.
public static LoggingIntervalPolicy OnlyOnce(string identifier)
Parameters
identifierstringUnique identifier for distinguishing logged events. Based on this identifier, the system will be able to determine if the event has already been logged.
Returns
- LoggingIntervalPolicy
Created logging policy configured for OnlyOnce policy.