How to: Clear 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 How to: Launch Event Viewer or your Event Viewer documentation. |
To clear an event log's contents from Server Explorer
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.
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.
Expand the Event Logs node.
You will see a list of the three main event logs — Application, Security, and System.
Right-click the log node you want to clear, and then click Clear Event Log.
Click Yes when prompted to confirm the deletion.
To clear an event log's contents programmatically
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.
Use the Clear method to clear the contents of the appropriate event log.
Your code should look something like this:
EventLog1.Clear()
EventLog1.Clear();
EventLog1.Clear();
See Also
Tasks
How to: Work with Event Logs in Server Explorer
How to: Launch Event Viewer
Walkthrough: Exploring Event Logs, Event Sources, and Entries
Reference
How to: Access and Initialize Server Explorer/Database Explorer