Query the Event Log (VB.NET)

Category:
C#, VB.NET, ASP.NET
Type:
Snippets
Difficulty:
Beginning
Author:
Intelligent Solutions Inc.

Version Compatibility: Visual Basic.NET

More information:
These are two functions designed to demonstrate how to read the event log in VB.NET. The first outputs information about all entries in all logs to the debug window. The second gets the last entry for the specified event log (or the Application log if no log is specified). These functions read from the event logs on the local machine, but you can read from any machine on the network, if the logged on use has permission, by passing the machine name to EventLog.GetEventLogs (see comments).

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: