|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionEver wanted to view the contents of the Windows event log from within your application? This article might be for you! BackgroundMany of the applications that I develop require some form of logging. I have found that logging to the Windows event log is simple and painless, but having to exit my application and go look in the Windows NT Event Viewer is tough as items get old very fast. One feature that I find lacking in the Windows Event Viewer is that you cannot search, filter, or sort the log entries. I created this component for just that purpose. Using the codeThe use of this component should be pretty straightforward. You need to add the component to the VS2005 toolbox, drag an In order to do the search/filter/sort, I used a There isn't really code that is breath-taking here. One problem I had was getting the ' Setup the dataset
' (Don't forget to set the DataType of the "Date/Time" column)
ds = New DataSet("EventLog Entries")
ds.Tables.Add("Events")
With ds.Tables("Events")
.Columns.Add("Type")
.Columns.Add("Date/Time")
.Columns("Date/Time").DataType = GetType(System.DateTime)
.Columns.Add("Message")
.Columns.Add("Source")
.Columns.Add("Category")
.Columns.Add("EventID")
End With
...
' Set the column type of the DataGridView as well!
If col.Name = "Date/Time" Then
col.ValueType = GetType(System.DateTime)
End If
Points of interestThe History
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||