G
Guest
I've created a basic Event Log monitoring application which is supposed to write a message to the console whenever the specified Event Log receives a new entry. The problem I'm having is that if the entries are created in rapid succession, the monitoring program is not notified of the event.
Since the ultimate goal of this project is to send a notification message whenever a file is deleted, I setup the test environment accordingly
- turn on object access auditing for Success in Local Security Polic
- change folder security to audit successful File/Folder Delete
- created a bunch of files in the audited folde
- started the monitoring application for the "Security" lo
If I delete one or two files, the monitoring program picks them up and writes the messages to the console (7 messages per file deleted). However, if I delete 10 or 20 files at a time, the monitor may catch one, a few, or none, but never all of them
I'm running the test on an XP Pro machine, using v1.1 of the CLR.
If anyone has any idea of where I'm going wrong, please speak up! The following is the code which I'm using
Imports Syste
Imports System.Environmen
Imports System.Diagnostic
Imports System.Threadin
Namespace LogMonito
Module LogMonito
Public Sub Main(
Dim args As String(
Dim appName As Strin
args = Environment.GetCommandLineArgs(
appName = args(0
If (args.Length <> 2 And args.Length <> 3) The
Console.WriteLine("Usage: " + appName + " <log> [<machine>]"
Console.WriteLine(
Console.WriteLine("Press Enter to continue..."
Console.ReadLine(
Exit Su
End I
Dim log As Strin
Dim machine As Strin
log = args(1
If (args.Length = 3) The
machine = args(2
Els
machine = "." ' local machin
End I
If (Not EventLog.Exists(log, machine)) The
Console.WriteLine("The log does not exist!"
Exit Su
End I
Dim aLog As EventLo
aLog = New EventLo
aLog.Log = lo
aLog.MachineName = machin
Console.WriteLine("Started monitoring for deleted files at " + DateString + " " + TimeString
AddHandler aLog.EntryWritten, AddressOf OnEntryWritte
aLog.EnableRaisingEvents = Tru
Console.WriteLine("Press 'q' to quit the sample"
While (Console.Read() <> 113
Thread.Sleep(500
End Whil
End Su
Sub OnEntryWritten(ByVal source As Object, ByVal e As EntryWrittenEventArgs
Tr
Console.WriteLine("Index: " + e.Entry.Index.ToString
+ " ID: "
+ e.Entry.EventID.ToString
Catch ex As Exceptio
Console.WriteLine(ex.Message
End Tr
Exit Su
End Su
End Modul
End Namespac
Since the ultimate goal of this project is to send a notification message whenever a file is deleted, I setup the test environment accordingly
- turn on object access auditing for Success in Local Security Polic
- change folder security to audit successful File/Folder Delete
- created a bunch of files in the audited folde
- started the monitoring application for the "Security" lo
If I delete one or two files, the monitoring program picks them up and writes the messages to the console (7 messages per file deleted). However, if I delete 10 or 20 files at a time, the monitor may catch one, a few, or none, but never all of them
I'm running the test on an XP Pro machine, using v1.1 of the CLR.
If anyone has any idea of where I'm going wrong, please speak up! The following is the code which I'm using
Imports Syste
Imports System.Environmen
Imports System.Diagnostic
Imports System.Threadin
Namespace LogMonito
Module LogMonito
Public Sub Main(
Dim args As String(
Dim appName As Strin
args = Environment.GetCommandLineArgs(
appName = args(0
If (args.Length <> 2 And args.Length <> 3) The
Console.WriteLine("Usage: " + appName + " <log> [<machine>]"
Console.WriteLine(
Console.WriteLine("Press Enter to continue..."
Console.ReadLine(
Exit Su
End I
Dim log As Strin
Dim machine As Strin
log = args(1
If (args.Length = 3) The
machine = args(2
Els
machine = "." ' local machin
End I
If (Not EventLog.Exists(log, machine)) The
Console.WriteLine("The log does not exist!"
Exit Su
End I
Dim aLog As EventLo
aLog = New EventLo
aLog.Log = lo
aLog.MachineName = machin
Console.WriteLine("Started monitoring for deleted files at " + DateString + " " + TimeString
AddHandler aLog.EntryWritten, AddressOf OnEntryWritte
aLog.EnableRaisingEvents = Tru
Console.WriteLine("Press 'q' to quit the sample"
While (Console.Read() <> 113
Thread.Sleep(500
End Whil
End Su
Sub OnEntryWritten(ByVal source As Object, ByVal e As EntryWrittenEventArgs
Tr
Console.WriteLine("Index: " + e.Entry.Index.ToString
+ " ID: "
+ e.Entry.EventID.ToString
Catch ex As Exceptio
Console.WriteLine(ex.Message
End Tr
Exit Su
End Su
End Modul
End Namespac