How to: Clear Event Logs 

.NET Framework 3.0

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.


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 How to: Launch 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 How to: Access and Initialize Server Explorer/Database Explorer.


    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.

  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 How to: Create EventLog Component Instances and How to: Configure EventLog Component Instances.

  2. Use the Clear method to clear the contents of the appropriate event log.

    Your code should look something like this:


See Also

Community Additions