Walkthrough: Populating and Raising an Event from Code

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

This walkthrough demonstrates the steps to populate and raise an event from code.

To reproduce the demonstration

  1. Create the information that will be submitted to the Logging Application Block.

    LogEntry log = new LogEntry();
    log.EventId = 300;
    log.Message = "Sample message";
    log.Categories.Add("UI Events");
    log.Severity = TraceEventType.Information;
    log.Priority = 5;
    
    'Usage
    Dim log As LogEntry = New LogEntry
    log.EventId = 300
    log.Message = "Sample message"
    log.Categories.Add("UI Events")
    log.Severity = TraceEventType.Information
    log.Priority = 5
    
  2. Call the static Write method on the Logger class, passing the LogEntry object.

    Logger.Write(log);
    
    'Usage
    Logger.Write(log)
    
Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.