How to: Access and Read Event Information

.NET Framework 3.5

When you obtain an event instance from an event query or subscription, you can read the value of the event properties. To do this, get the XML representation of the event or specify the name of the property to be read.

For more information about how to query for events, see How to: Query for Events. For more information about how to subscribe to events, see How to: Subscribe to Events in an Event Log.

Example

Description

The following code example queries for all the level 2 events in the Application log, and then displays the XML representation for each event. Each event instance returned from the event query is represented by an EventRecord instance. The ToXml method is called to obtain the XML representation of the event.

Code

No code example is currently available or this language may not be supported.

Compiling the Code

This code example requires references to the System.dll and System.Core.dll files.

Example

Description

The following code example uses the EventLogPropertySelector class to render an event instance as a list of specified values. The specified values are the user that logged the event, the time the event was created, the event identifier, and the event record identifier.

Code

No code example is currently available or this language may not be supported.

Compiling the Code

This example requires references to the System.dll and System.Core.dll files.

See Also

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.

Community Additions

Show: