Reputation: 1975
I am running a filesystemwatcher on the "w3svc1" folder, where the iis logs are stored by default. When I go to the adress localhost or anyone of my webapp localhost/xxxxx. The filesystemwatcher does not raise events. I know that there is a delay between the request and the writting in the logs, but even after one hour there is no change event raised. But then, when I open the file with notepad++, I see the logs added. Is anyone has an explaination. This is my code:
class Program
{
static void Main(string[] args)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"C:\inetpub\logs\LogFiles\W3SVC1";
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.IncludeSubdirectories = true;
watcher.Filter = "*.log";
watcher.Changed += new FileSystemEventHandler(OnChangedok);
watcher.Created += new FileSystemEventHandler(OnChangedok);
watcher.EnableRaisingEvents = true;
Console.WriteLine("Press \'q\' to quit the sample.");
while (Console.Read() != 'q') ;
}
private static void OnChangedok(object source, FileSystemEventArgs e)
{
Console.WriteLine(e.FullPath);
}
Upvotes: 1
Views: 792