System.Diagnostics.EventLog.ModifyOverflowPolicy Method

Changes the configured behavior for writing new entries when the event log reaches its maximum file size.

Syntax

[System.MonoTODO]
[System.Runtime.InteropServices.ComVisible(false)]
public void ModifyOverflowPolicy (OverflowAction action, int retentionDays)

Parameters

action
The overflow behavior for writing new entries to the event log.
retentionDays
The minimum number of days each event log entry is retained. This parameter is used only if action is set to OverflowAction.OverwriteOlder.

Remarks

The overflow behavior for an event log specifies what happens when new entries are to be written to a log that has reached its maximum file size.

Note:

The overflow behavior takes effect only when an event log reaches its maximum file size. The overflow behavior does not affect writing a new entry to a log that can accommodate additional event log entries.

The EventLog.ModifyOverflowPolicy(OverflowAction, int) method configures the overflow behavior of an event log. System.Diagnostics.EventLog instance. After calling this method for the event log specified by the EventLog.Log property, the EventLog.OverflowAction and EventLog.MinimumRetentionDays property values reflect the newly configured overflow behavior.

Note:

This property represents a configuration setting for the event log represented by this instance. When the event log reaches its maximum size, this property specifies how the operating system handles new entries written by all event sources registered for the event log.

Set the action parameter to OverflowAction.OverwriteAsNeeded to indicate that a new entry overwrites the oldest entry when the System.Diagnostics.EventLog reaches its maximum size. If the action parameter is set to OverflowAction.OverwriteAsNeeded, the retentionDays parameter value is ignored.

Set the action parameter to OverflowAction.OverwriteOlder to indicate that each new entry overwrites older entries when the System.Diagnostics.EventLog reaches its maximum size. Specify the number of days that events must be retained in the log using the retentionDays parameter. Events written within the retention range are not overwritten by new entries.

Set the action parameter to OverflowAction.DoNotOverwrite to discard new events when the maximum log size is reached. If the action parameter is set to OverflowAction.DoNotOverwrite, the retentionDays parameter value is ignored.

Note:

Setting the overflow policy to OverflowAction.DoNotOverwrite specifies that new entries are discarded when the event log is full. If you use this setting, ensure the event log is regularly archived and cleared to avoid reaching its maximum size limit.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0