Before your component can write an entry to an event log, you must register it with the event log as a valid source of events. You can do this by using the CreateEventSource method and specifying a string that uniquely identifies your component to the event log. When you write a log entry, the system uses the source you identified to find the appropriate log in which to place your entry. Your EventLog component can write to only a single log at a time.
Note By default, if you try to write an entry without first having registered your component as a valid source, the source is automatically registered with the event log, using the value of the Source property as the source string.
If you specify the name of a log that does not exist when you use the CreateEventSource method, the system creates a new, custom event log for you with that name. For more information, see Creating and Removing Custom Event Logs.
To establish your component as an event source on the local computer
[Visual Basic] EventLog.CreateEventSource("MyApp1", "Application") [C#] EventLog.CreateEventSource("MyApp1", "Application");
Note If you do not specify a log name, it defaults to Application.
To establish your component as an event source on a remote computer
[Visual Basic] EventLog.CreateEventSource("MyApp1", "Application", "myserver") [C#] EventLog.CreateEventSource("MyApp1", "Application", "myserver");
Determining Whether an Event Source Exists | Removing an Event Source | Introduction to the EventLog Component | Creating and Removing Custom Event Logs