NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Writing Entries to Event Logs

When you write an entry to an event log, you specify the message you want to write to the log as a string. A message should contain all information needed to interpret what caused the problem and what to do to correct the problem.

The following conditions must be met in order to successfully write a log entry:

You can specify several parameters when you write an entry, including the type of entry you're making, an ID that identifies the message, a category, and any binary data you want to append to the entry. For more information on the properties associated with an entry, see EventLog Members.

To write an event log entry

  1. Create an instance of the EventLog component. For details, see Creating EventLog Components .
  2. Set the Log, MachineName, and Source properties for the component. For details, see Configuring EventLog Components.
    Note If you have already registered the source with the event log to which you want to write an entry, you need only set the Source property in this step.
  3. Use the WriteEntry method to specify the entry to be written to the log. Your code might look something like the following:
    [Visual Basic]
         EventLog1.WriteEntry("This is a simple event log entry")
    [C#]
         EventLog1.WriteEntry ("This is a simple event log entry");

See Also

Introduction to the EventLog Component  | Configuring EventLog Components | Creating EventLog Components  | EventLog Members