This documentation is archived and is not being maintained.

Clearing Event Logs

Event logs are set to a maximum size that determines how many entries each log can contain. When an event log is full, it will either stop recording entries or begin overwriting the oldest entries with new entries, depending on the log's settings in the Windows Event Viewer. In either case, you can clear the log of its existing entries to free the log and allow it to start recording events again. You must have Administrator rights to the computer on which the log resides in order to clear entries.

By default, the Application, System, and Security logs are set to a default maximum size of 4992 K. Custom logs are set to a default maximum of 512 K.

Note   You can also use the Windows Event Viewer to free up space on a log that has become full. You can set the log to overwrite existing events, you can write log entries to an external file, or you can increase the maximum size of the log. You cannot, however, remove only some of the entries in a log; when you clear a log, you remove all of its contents. For more information, see Launching Event Viewer or your Event Viewer documentation.

To clear an event log's contents from Server Explorer

  1. Open Server Explorer, and then expand the node for the server on which the event log you want to clear resides. For more information, see Accessing and Initializing Server Explorer.
    Tip   If you do not see the server you want listed in the Servers node, right-click Servers, click Add Server, enter the name of your server, and then click OK.
    Note   The Servers node of Server Explorer is not available in the Standard Edition of Visual Basic and Visual C# .NET. For more information, see Visual Basic Standard Edition Features or Visual C# Standard Edition Features.
  2. Expand the Event Logs node.

    You will see a list of the three main event logs — Application, Security, and System.

  3. Right-click the log node you want to clear, and then click Clear Event Log.
  4. Click Yes when prompted to confirm the deletion.

To clear an event log's contents programmatically

  1. Create an instance of the EventLog component and set the necessary properties to configure it. For more information, see Creating EventLog Component Instances and Configuring EventLog Component Instances.
  2. Use the EventLog.Clear method to clear the contents of the appropriate event log.

    Your code should look something like this:

    ' Visual Basic
    // C#

See Also

Working with Event Logs in Server Explorer | Launching Event Viewer | Accessing and Initializing Server Explorer | Administering Event Logs | Walkthrough: Exploring Event Logs, Event Sources, and Entries