Bewerken

Share via


EntryWrittenEventArgs.Entry Property

Definition

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

public:
 property System::Diagnostics::EventLogEntry ^ Entry { System::Diagnostics::EventLogEntry ^ get(); };
public System.Diagnostics.EventLogEntry Entry { get; }
member this.Entry : System.Diagnostics.EventLogEntry
Public ReadOnly Property Entry As EventLogEntry

Property Value

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

Examples

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.

void MyOnEntry( Object^ source, EntryWrittenEventArgs^ e )
{
   EventLogEntry^ myEventLogEntry = e->Entry;
   if ( myEventLogEntry )
   {
      Console::WriteLine( "Current message entry is: '{0}'", myEventLogEntry->Message );
   }
   else
   {
      Console::WriteLine( "The current entry is null" );
   }
}
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");
    }
}
Protected Shared Sub MyOnEntry(source As Object, e As EntryWrittenEventArgs)
   Dim myEventLogEntry As EventLogEntry = e.Entry
   If Not (myEventLogEntry Is Nothing) Then
      Console.WriteLine("Current message entry is: '" + _
                                          myEventLogEntry.Message + "'")
   Else
      Console.WriteLine("The current entry is null")
   End If
End Sub

Applies to