Removing an Event Source
You can remove your source if you no longer need to use it to write entries to that log. Doing so affects all components that used that source to write to the log. For example, if you have two components that write to a log using the source string "mysource," removing "mysource" as a valid source of events affects both the components.
You might remove an event source if you were changing your source from one log to another. For example, suppose you want to stop writing entries to an OrdersProcessed log and start writing entries to an OrdersSent log. First, you would remove the association of the source with the first log, and then you would register the source with the new log to which you wanted to write events.
To remove an event source
- Call the EventLog.DeleteEventSource method, specifying the source name to remove.
The following example shows how to unregister an event source named MyApp1 from the local machine. This code assumes that an Imports or Using statement exists for the System.Diagnostics namespace:
' Visual Basic EventLog.DeleteEventSource("MyApp1") // C# System.Diagnostics.EventLog.DeleteEventSource("MyApp1");Tip To remove an event source from a remote computer, specify the computer name as a second parameter. The following code shows an example:
' Visual Basic EventLog.DeleteEventSource("MyApp1", "myserver") // C# System.Diagnostics.EventLog.DeleteEventSource("MyApp1", "myserver");Note Removing a source does not remove the entries that were written to that log using this source. However, it does affect the entries by adding information to them indicating that the source cannot be found.