EventLogEntry Class
Encapsulates a single record in the event log. This class cannot be inherited.
System::MarshalByRefObject
System.ComponentModel::Component
System.Diagnostics::EventLogEntry
Assembly: System (in System.dll)
The EventLogEntry type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CanRaiseEvents | Gets a value indicating whether the component can raise an event. (Inherited from Component.) |
![]() | Category | Gets the text associated with the CategoryNumber property for this entry. |
![]() | CategoryNumber | Gets the category number of the event log entry. |
![]() | Container | Gets the IContainer that contains the Component. (Inherited from Component.) |
![]() | Data | Gets the binary data associated with the entry. |
![]() | DesignMode | Gets a value that indicates whether the Component is currently in design mode. (Inherited from Component.) |
![]() | EntryType | Gets the event type of this entry. |
![]() | EventID | Obsolete. Gets the application-specific event identifier for the current event entry. |
![]() | Events | Gets the list of event handlers that are attached to this Component. (Inherited from Component.) |
![]() | Index | Gets the index of this entry in the event log. |
![]() | InstanceId | Gets the resource identifier that designates the message text of the event entry. |
![]() | MachineName | Gets the name of the computer on which this entry was generated. |
![]() | Message | Gets the localized message associated with this event entry. |
![]() | ReplacementStrings | Gets the replacement strings associated with the event log entry. |
![]() | Site | Gets or sets the ISite of the Component. (Inherited from Component.) |
![]() | Source | Gets the name of the application that generated this event. |
![]() | TimeGenerated | Gets the local time at which this event was generated. |
![]() | TimeWritten | Gets the local time at which this event was written to the log. |
![]() | UserName | Gets the name of the user who is responsible for this event. |
| Name | Description | |
|---|---|---|
![]() | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) |
![]() | Dispose() | Releases all resources used by the Component. (Inherited from Component.) |
![]() | Dispose(Boolean) | Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.) |
![]() | Equals(EventLogEntry) | Performs a comparison between two event log entries. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
![]() | GetService | Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
![]() | MemberwiseClone() | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) |
![]() | ToString | Returns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ISerializable::GetObjectData | Infrastructure. Populates a SerializationInfo with the data needed to serialize the target object. |
You usually will not create instances of EventLogEntry directly when working with the EventLog class. The Entries member of the EventLog class contains a collection of EventLogEntry instances, which you iterate over when reading by using the EventLogEntryCollection::Item class index member.
Windows 98, Windows Millennium Edition Platform Note: Event logs are not supported on Windows 98 or Windows Millennium.
The following code example demonstrates the use of the EventLogEntry class. In this example, a switch statement uses console input to search for event log entries for the specified event type. If a match is found, log entry source information is displayed at the console.
#using <System.dll> using namespace System; using namespace System::Diagnostics; int main() { String^ myEventType = nullptr; // Associate the instance of 'EventLog' with local System Log. EventLog^ myEventLog = gcnew EventLog( "System","." ); Console::WriteLine( "1:Error" ); Console::WriteLine( "2:Information" ); Console::WriteLine( "3:Warning" ); Console::WriteLine( "Select the Event Type" ); int myOption = Convert::ToInt32( Console::ReadLine() ); switch ( myOption ) { case 1: myEventType = "Error"; break; case 2: myEventType = "Information"; break; case 3: myEventType = "Warning"; break; default: break; } EventLogEntryCollection^ myLogEntryCollection = myEventLog->Entries; int myCount = myLogEntryCollection->Count; // Iterate through all 'EventLogEntry' instances in 'EventLog'. for ( int i = myCount - 1; i > 0; i-- ) { EventLogEntry^ myLogEntry = myLogEntryCollection[ i ]; // Select the entry having desired EventType. if ( myLogEntry->EntryType.Equals( myEventType ) ) { // Display Source of the event. Console::WriteLine( "{0} was the source of last event of type {1}", myLogEntry->Source, myLogEntry->EntryType ); return 0; } } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
