Skip to content

Fix descriptions of invalid eventlog overflow policy #9293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 20 additions & 25 deletions xml/System.Diagnostics/EventLog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2510,22 +2510,18 @@ SVC_UPDATE.EXE
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the number of days to retain entries in the event log.</summary>
<value>The number of days that entries in the event log are retained. The default value is 7.</value>
<summary>This property is deprecated.</summary>
<value>To be added.</value>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
Use the <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> property to examine the current setting for an event log. Use <xref:System.Diagnostics.EventLog.ModifyOverflowPolicy%2A> to change the minimum number of days that each entry in the event log must be retained.

The <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> value depends on the configured overflow behavior of the event log. If the <xref:System.Diagnostics.OverflowAction> property for an event log is set to <xref:System.Diagnostics.OverflowAction.OverwriteAsNeeded>, then the <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> value is 0. If the <xref:System.Diagnostics.OverflowAction> property for an event log is set to <xref:System.Diagnostics.OverflowAction.DoNotOverwrite>, then the <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> value is -1. If the <xref:System.Diagnostics.OverflowAction> property for an event log is set to <xref:System.Diagnostics.OverflowAction.OverwriteOlder>, then the <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> value is greater than zero, and represents the number of days to retain event log entries when the event log is full.
<format type="text/markdown"><![CDATA[

## Remarks

The overflow behavior only occurs when an event log reaches its size limit. When an <xref:System.Diagnostics.EventLog> has its <xref:System.Diagnostics.EventLog.OverflowAction%2A> set to <xref:System.Diagnostics.OverflowAction.OverwriteOlder>, and the event log reaches its maximum size, then new entries are written only if they can replace entries whose age exceeds the <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> period. Retaining event entries for a minimum period is appropriate when the event log is archived regularly. Otherwise, you risk losing new entries when the event log reaches its limit. To avoid losing new event information, set the minimum retention days for events based on your archive schedule for a particular event log.



## Examples
The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log.
> [!IMPORTANT]
> Support for the <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> property was removed in Windows Vista and later operating systems. Setting this value can cause the Event Log to never overwrite events, and to drop all events to the channel once it is full.

## Examples
The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log.

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2":::
Expand Down Expand Up @@ -2576,8 +2572,8 @@ SVC_UPDATE.EXE
<Parameter Name="retentionDays" Type="System.Int32" Index="1" FrameworkAlternate="net-10.0-pp;net-8.0-pp;net-9.0-pp;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-2.0-pp;windowsdesktop-10.0;windowsdesktop-3.0;windowsdesktop-3.1;windowsdesktop-5.0;windowsdesktop-6.0;windowsdesktop-7.0;windowsdesktop-8.0;windowsdesktop-9.0" />
</Parameters>
<Docs>
<param name="action">The overflow behavior for writing new entries to the event log.</param>
<param name="retentionDays">The minimum number of days each event log entry is retained. This parameter is used only if <paramref name="action" /> is set to <see cref="F:System.Diagnostics.OverflowAction.OverwriteOlder" />.</param>
<param name="action">The overflow behavior for writing new entries to the event log. Must not be `OverwriteOlder`.</param>
<param name="retentionDays">Deprecated. Must be 0.</param>
<summary>Changes the configured behavior for writing new entries when the event log reaches its maximum file size.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
Expand All @@ -2586,23 +2582,22 @@ SVC_UPDATE.EXE
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 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 <xref:System.Diagnostics.EventLog.ModifyOverflowPolicy%2A> method configures the overflow behavior of an event log. <xref:System.Diagnostics.EventLog> instance. After calling this method for the event log specified by the <xref:System.Diagnostics.EventLog.Log%2A> property, the <xref:System.Diagnostics.EventLog.OverflowAction%2A> and <xref:System.Diagnostics.EventLog.MinimumRetentionDays%2A> 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.
> 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 <xref:System.Diagnostics.OverflowAction.OverwriteAsNeeded> to indicate that a new entry overwrites the oldest entry when the <xref:System.Diagnostics.EventLog> reaches its maximum size. If the `action` parameter is set to <xref:System.Diagnostics.OverflowAction.OverwriteAsNeeded>, the `retentionDays` parameter value is ignored.

Set the `action` parameter to <xref:System.Diagnostics.OverflowAction.OverwriteAsNeeded> to indicate that a new entry overwrites the oldest entry when the <xref:System.Diagnostics.EventLog> reaches its maximum size. If the `action` parameter is set to <xref:System.Diagnostics.OverflowAction.OverwriteAsNeeded>, the `retentionDays` parameter value is ignored.
Set the `action` parameter to <xref:System.Diagnostics.OverflowAction.DoNotOverwrite> to discard new events when the maximum log size is reached. If the `action` parameter is set to <xref:System.Diagnostics.OverflowAction.DoNotOverwrite>, the `retentionDays` parameter value is ignored.

Set the `action` parameter to <xref:System.Diagnostics.OverflowAction.OverwriteOlder> to indicate that each new entry overwrites older entries when the <xref: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 <xref:System.Diagnostics.OverflowAction.DoNotOverwrite> to discard new events when the maximum log size is reached. If the `action` parameter is set to <xref:System.Diagnostics.OverflowAction.DoNotOverwrite>, the `retentionDays` parameter value is ignored.
> [!WARNING]
> Never set the `action` parameter to <xref:System.Diagnostics.OverflowAction.OverwriteOlder>. This value is deprecated and might cause the log to behave as if the `DoNotOverwrite` parameter was passed instead.

> [!CAUTION]
> Setting the overflow policy to <xref:System.Diagnostics.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.


> Setting the overflow policy to <xref:System.Diagnostics.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.

## Examples
The following example displays the configured overflow policy for a specified event log, and allows the user to select a new overflow policy setting for the event log.
Expand Down
13 changes: 7 additions & 6 deletions xml/System.Diagnostics/OverflowAction.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@

- New entries will be discarded.

- New entries will overwrite older entries.

- New entries will either be discarded or will overwrite existing entries depending upon the age of the existing entries.
- New entries will overwrite older entries.

Use the <xref:System.Diagnostics.EventLog.ModifyOverflowPolicy%2A> method to set the overflow behavior for an <xref:System.Diagnostics.EventLog>. Check the current configured behavior of an <xref:System.Diagnostics.EventLog> through its <xref:System.Diagnostics.EventLog.OverflowAction%2A> property.

> [!WARNING]
> The `OverwriteOlder` behavior is deprecated. Using this value might cause the Event Log to behave as if the `DoNotOverwrite` value was used instead, which will cause events to be discarded when the log is full.

## Examples

The following example enumerates the event logs defined on the local computer and displays configuration details for each event log.
Expand Down Expand Up @@ -149,17 +150,17 @@ The following example enumerates the event logs defined on the local computer an
</ReturnValue>
<MemberValue>1</MemberValue>
<Docs>
<summary>Indicates that new events overwrite events older than specified by the <see cref="P:System.Diagnostics.EventLog.MinimumRetentionDays" /> property value when the event log is full. New events are discarded if the event log is full and there are no events older than specified by the <see cref="P:System.Diagnostics.EventLog.MinimumRetentionDays" /> property value.</summary>
<summary>This field is deprecated.</summary>
<remarks>
<format type="text/markdown"><![CDATA[

> [!WARNING]
> Do not use this value. Doing so might cause the Event Log to behave as if the `DoNotOverwrite` value was used instead.

]]></format>
</remarks>
<altmember cref="T:System.Diagnostics.EventLog" />
<altmember cref="P:System.Diagnostics.EventLog.OverflowAction" />
<altmember cref="P:System.Diagnostics.EventLog.MaximumKilobytes" />
<altmember cref="P:System.Diagnostics.EventLog.MinimumRetentionDays" />
<altmember cref="M:System.Diagnostics.EventLog.ModifyOverflowPolicy(System.Diagnostics.OverflowAction,System.Int32)" />
</Docs>
</Member>
Expand Down