EventLog.ModifyOverflowPolicy メソッド
アセンブリ: System (system.dll 内)
構文<ComVisibleAttribute(False)> _ Public Sub ModifyOverflowPolicy ( _ action As OverflowAction, _ retentionDays As Integer _ )
Dim instance As EventLog Dim action As OverflowAction Dim retentionDays As Integer instance.ModifyOverflowPolicy(action, retentionDays)
[ComVisibleAttribute(false)] public void ModifyOverflowPolicy ( OverflowAction action, int retentionDays )
[ComVisibleAttribute(false)] public: void ModifyOverflowPolicy ( OverflowAction action, int retentionDays )
/** @attribute ComVisibleAttribute(false) */ public void ModifyOverflowPolicy ( OverflowAction action, int retentionDays )
ComVisibleAttribute(false) public function ModifyOverflowPolicy ( action : OverflowAction, retentionDays : int )
例外
解説イベント ログのオーバーフロー動作によって、最大ファイル サイズに達したログに新しいエントリが書き込まれる場合の動作が指定されます。
注意 |
|---|
| オーバーフロー ポリシーを DoNotOverwrite に設定すると、イベント ログがいっぱいになった場合に新しいエントリが破棄されます。この設定を使用する場合は、イベント ログを定期的にアーカイブして、最大サイズ制限に達しないようにします。 |
使用例指定したイベント ログに構成されたオーバーフロー ポリシーを表示し、ユーザーがイベント ログに新しいオーバーフロー ポリシー設定を選択できるようにする例を次に示します。
' Display the current event log overflow settings, and ' prompt the user to input a new overflow setting. Shared Sub ChangeEventLogOverflowAction(logName As String) If EventLog.Exists(logName) Then Dim inputLog As EventLog = New EventLog(logName) Console.WriteLine(" Event log {0}", inputLog.Log) Dim logOverflow As OverflowAction = inputLog.OverflowAction Dim numDays As Int32 = inputLog.MinimumRetentionDays Console.WriteLine(" Current overflow setting = {0}", _ logOverflow.ToString()) ' Prompt user for a new overflow setting. GetNewOverflowSetting(logOverflow, numDays) If Not logOverflow = inputLog.OverflowAction Then inputLog.ModifyOverflowPolicy(logOverflow, numDays) Console.WriteLine("Event log overflow policy was modified successfully!") Else Console.WriteLine("Event log overflow policy was not modified.") End If Else Console.WriteLine("Event log {0} was not found.", logName) End If End Sub
// Display the current event log overflow settings, and // prompt the user to input a new overflow setting. public static void ChangeEventLogOverflowAction(String logName) { if (EventLog.Exists(logName)) { // Display the current overflow setting of the // specified event log. EventLog inputLog = new EventLog(logName); Console.WriteLine(" Event log {0}", inputLog.Log); OverflowAction logOverflow = inputLog.OverflowAction; Int32 numDays = inputLog.MinimumRetentionDays; Console.WriteLine(" Current overflow setting = {0}", logOverflow.ToString()); if (logOverflow == OverflowAction.OverwriteOlder) { Console.WriteLine("\t Entries are retained a minimum of {0} days.", numDays.ToString()); } // Prompt user for a new overflow setting. GetNewOverflowSetting(ref logOverflow, ref numDays); // Change the overflow setting on the event log. if (logOverflow != inputLog.OverflowAction) { inputLog.ModifyOverflowPolicy(logOverflow, numDays); Console.WriteLine("Event log overflow policy was modified successfully!"); } else { Console.WriteLine("Event log overflow policy was not modified."); } } else { Console.WriteLine("Event log {0} was not found.", logName); } }
// Display the current event log overflow settings, and // prompt the user to input a new overflow setting. public static void ChangeEventLogOverflowAction(String logName) { if (EventLog.Exists(logName)) { // Display the current overflow setting of the // specified event log. EventLog inputLog = new EventLog(logName); Console.WriteLine(" Event log {0}", inputLog.get_Log()); OverflowAction logOverflow = inputLog.get_OverflowAction(); int numDays = inputLog.get_MinimumRetentionDays(); Console.WriteLine(" Current overflow setting = {0}", logOverflow.ToString()); if (logOverflow.Equals(OverflowAction.OverwriteOlder)) { Console.WriteLine("\t Entries are retained a minimum of {0} " + "days.",((Int32)numDays).ToString()); } // Prompt user for a new overflow setting. GetNewOverflowSetting(logOverflow, numDays); // Change the overflow setting on the event log. if (logOverflow != inputLog.get_OverflowAction()) { inputLog.ModifyOverflowPolicy(logOverflow, numDays); Console.WriteLine("Event log overflow policy was modified " + "successfully!"); } else { Console.WriteLine("Event log overflow policy was not " + "modified."); } } else { Console.WriteLine("Event log {0} was not found.", logName); } } //ChangeEventLogOverflowAction
.NET Framework のセキュリティ
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照EventLog クラス
EventLog メンバ
System.Diagnostics 名前空間
OverflowAction
MaximumKilobytes
OverflowAction
MinimumRetentionDays
- EventLog.ModifyOverflowPolicy メソッドのページへのリンク
.gif)