Skip to content

Commit 2427e62

Browse files
authored
Fix descriptions of invalid eventlog overflow policy (#9293)
1 parent 8857bc6 commit 2427e62

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

xml/System.Diagnostics/EventLog.xml

+20-25
Original file line numberDiff line numberDiff line change
@@ -2510,22 +2510,18 @@ SVC_UPDATE.EXE
25102510
<ReturnType>System.Int32</ReturnType>
25112511
</ReturnValue>
25122512
<Docs>
2513-
<summary>Gets the number of days to retain entries in the event log.</summary>
2514-
<value>The number of days that entries in the event log are retained. The default value is 7.</value>
2513+
<summary>This property is deprecated.</summary>
2514+
<value>To be added.</value>
25152515
<remarks>
2516-
<format type="text/markdown"><![CDATA[
2517-
2518-
## Remarks
2519-
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.
2520-
2521-
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.
2516+
<format type="text/markdown"><![CDATA[
2517+
2518+
## Remarks
25222519
2523-
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.
2524-
2525-
2526-
2527-
## Examples
2528-
The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log.
2520+
> [!IMPORTANT]
2521+
> 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.
2522+
2523+
## Examples
2524+
The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log.
25292525
25302526
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2":::
25312527
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2":::
@@ -2576,8 +2572,8 @@ SVC_UPDATE.EXE
25762572
<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" />
25772573
</Parameters>
25782574
<Docs>
2579-
<param name="action">The overflow behavior for writing new entries to the event log.</param>
2580-
<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>
2575+
<param name="action">The overflow behavior for writing new entries to the event log. Must not be `OverwriteOlder`.</param>
2576+
<param name="retentionDays">Deprecated. Must be 0.</param>
25812577
<summary>Changes the configured behavior for writing new entries when the event log reaches its maximum file size.</summary>
25822578
<remarks>
25832579
<format type="text/markdown"><![CDATA[
@@ -2586,23 +2582,22 @@ SVC_UPDATE.EXE
25862582
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.
25872583
25882584
> [!NOTE]
2589-
> 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.
2585+
> 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.
25902586
25912587
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.
25922588
25932589
> [!NOTE]
2594-
> 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.
2590+
> 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.
2591+
2592+
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.
25952593
2596-
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.
2594+
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.
25972595
2598-
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.
2599-
2600-
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.
2596+
> [!WARNING]
2597+
> 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.
26012598
26022599
> [!CAUTION]
2603-
> 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.
2604-
2605-
2600+
> 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.
26062601
26072602
## Examples
26082603
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.

xml/System.Diagnostics/OverflowAction.xml

+7-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
3939
- New entries will be discarded.
4040
41-
- New entries will overwrite older entries.
42-
43-
- New entries will either be discarded or will overwrite existing entries depending upon the age of the existing entries.
41+
- New entries will overwrite older entries.
4442
4543
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.
4644
45+
> [!WARNING]
46+
> 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.
47+
4748
## Examples
4849
4950
The following example enumerates the event logs defined on the local computer and displays configuration details for each event log.
@@ -149,17 +150,17 @@ The following example enumerates the event logs defined on the local computer an
149150
</ReturnValue>
150151
<MemberValue>1</MemberValue>
151152
<Docs>
152-
<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>
153+
<summary>This field is deprecated.</summary>
153154
<remarks>
154155
<format type="text/markdown"><![CDATA[
155-
156+
> [!WARNING]
157+
> Do not use this value. Doing so might cause the Event Log to behave as if the `DoNotOverwrite` value was used instead.
156158
157159
]]></format>
158160
</remarks>
159161
<altmember cref="T:System.Diagnostics.EventLog" />
160162
<altmember cref="P:System.Diagnostics.EventLog.OverflowAction" />
161163
<altmember cref="P:System.Diagnostics.EventLog.MaximumKilobytes" />
162-
<altmember cref="P:System.Diagnostics.EventLog.MinimumRetentionDays" />
163164
<altmember cref="M:System.Diagnostics.EventLog.ModifyOverflowPolicy(System.Diagnostics.OverflowAction,System.Int32)" />
164165
</Docs>
165166
</Member>

0 commit comments

Comments
 (0)