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 EventLog.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 instance 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 system automatically registers the source 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 the first time you try to write an entry to the log. For more information, see Creating and Removing Custom Event Logs.
To establish your component as an event source
See Also
Determining If an Event Source Exists | Removing an Event Source | Introduction to the EventLog Component | Creating and Removing Custom Event Logs | Walkthrough: Exploring Event Logs, Event Sources, and Entries