Event Log Watcher Problem

bhenry

New member
Joined
May 12, 2008
Messages
1
Programming Experience
Beginner
I'm writing a web application in VB.NET which monitors the windows event log and waits for a change. The log is written by a windows service which monitors a database for a change. I'm using same basic code that I found in several different places:

Dim objLog As EventLog = New EventLog("Application", ".", "MyService")

AddHandler objLog.EntryWritten, AddressOf ApplicationLog_OnEntryWritten
objLog.EnableRaisingEvents = True


Public Sub ApplicationLog_OnEntryWritten(ByVal [source] As Object, ByVal e As EntryWrittenEventArgs)

Debug.Print("Data Changed 8 " & e.Entry.ToString & vbNewLine & e.Entry.TimeGenerated & vbNewLine & e.Entry.TimeWritten)

End Sub

When I change the database the event log is written and the program prints to the debug window. If I change the data base again and again the debug message is written again but with the previous debug message. Even if I stop the debugger and quit studio, when I restart I'll change the counter on the debug statement and the old numbers will come back. This happens until I reboot.

So the question is how do I simply run code to do something when the event log update event is triggered?

Thanks.

Below is a typical debug message written after the debug window was cleared and the database updated (Data Changed 5 is after I rebooted):

Data Changed 6
Data Changed 6
Data Changed 6
Data Changed 6
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 7 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 7 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 6
Data Changed 6
Data Changed 5
Data Changed 5
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
Data Changed 8 System.Diagnostics.EventLogEntry
5/12/2008 4:13:44 PM
5/12/2008 4:13:44 PM
 
Back
Top