EntryWrittenEventArgs.Entry Property

 
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.

Gets the event log entry that was written to the log.

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

public EventLogEntry Entry { get; }

Property Value

Type: System.Diagnostics.EventLogEntry

An EventLogEntry that represents the entry that was written to the event log.

The following example assumes that you have already implemented the sample in EntryWrittenEventArgs(EventLogEntry).

It creates a custom EventLog object and writes an entry into it. Then it creates an EntryWrittenEventArgs object using the first entry in the custom EventLog. This object is used to notify a message.

protected static void MyOnEntry(Object source, EntryWrittenEventArgs e)
{
    EventLogEntry myEventLogEntry = e.Entry;
    if (myEventLogEntry != null)
    {
        Console.WriteLine("Current message entry is: '"
                          + myEventLogEntry.Message + "'");
    }
    else
    {
        Console.WriteLine("The current entry is null");
    }
}

.NET Framework
Available since 1.1
Return to top
Show: