EventLog.Clear Method ()
Removes all entries from the event log.
Assembly: System (in System.dll)
The event log was not cleared successfully.
The log cannot be opened. A Windows error code is not available.
A value is not specified for the Log property. Make sure the log name is not an empty string.
The log does not exist.
Event logs are set with a maximum size that determines how many entries they can contain. When an event log is full, it stops recording new event information or begins to overwrite earlier entries. If event recording stops, you can use this method to clear the log of existing entries and allow it to start recording events again. You must have administrator permissions to the computer on which the log resides to clear event log entries.
closes the event log, releases the event handles, retrieves new read and write handles, and reopens the event log. Events received after the call to the method are not cleared along with the existing events.
The following example clears an event log.
Because Application, System, Security, and other non-custom logs can contain crucial information; be sure to specify a custom log before executing this example code. This example deletes the custom log myNewLog.
Option Explicit Option Strict Imports System Imports System.Diagnostics Imports System.Threading Class MySample Public Shared Sub Main() ' Create an EventLog instance and assign its log name. Dim myLog As New EventLog() myLog.Log = "myNewLog" myLog.Clear() End Sub 'Main End Class 'MySample
Available since 1.1