System.Diagnostics.EventLog.DeleteEventSource Method

Removes the event source registration from the event log of the local computer.

Syntax

public static void DeleteEventSource (string source)

Parameters

source
The name by which the application is registered in the event log system.

Remarks

Use this method to remove the registration of a EventLog.Source from the local computer. EventLog.DeleteEventSource(string) accesses the registry on the local computer and removes the registration of your application as a valid source of events.

You can remove your component as a valid source of events if you no longer need it to write entries to that log. For example, you might do this if you need to change your component from one log to another. Because a source can only be registered to one log at a time, changing the log requires you to remove the current registration.

EventLog.DeleteEventSource(string) removes only the source registered to a log. If you want to remove the log itself, call EventLog.Delete(string). If you only want to delete the log entries, call EventLog.Clear. EventLog.Delete(string) and EventLog.DeleteEventSource(string) are static methods, so they can be called on the class itself. It is not necessary to create an instance of System.Diagnostics.EventLog to call either method.

Deleting a log through a call to EventLog.Delete(string) automatically deletes the sources registered to that log. This can make other applications using that log inoperative.

Note:

If a source has already been mapped to a log and you remap it to a new log, you must restart the computer for the changes to take effect.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0