EventLog.DeleteEventSource Method (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

static member DeleteEventSource : 
        source:string -> unit

Parameters

source
Type: System.String

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

Exception Condition
ArgumentException

The source parameter does not exist in the registry of the local computer.

- or -

You do not have write access on the registry key for the event log.

Use this method to remove the registration of a Source from the local computer. DeleteEventSource 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.

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

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

System_CAPS_noteNote

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.

The following example deletes a source from the local computer. The example determines the log from its source, and then deletes the log.

System_CAPS_noteNote

More than one source might write to an event log. Before deleting a custom log, make sure there are no other sources writing to that log.

No code example is currently available or this language may not be supported.

EventLogPermission

for administering event log information on the computer. Associated enumeration: EventLogPermissionAccess.Administer

.NET Framework
Available since 1.1
Return to top
Show: