c# - Detect changes in iis logs files -


i running filesystemwatcher on "w3svc1" folder, iis logs stored default. when go adress localhost or of webapp localhost/xxxxx. filesystemwatcher not raise events. know there delay between request , writting in logs, after 1 hour there no change event raised. then, when open file notepad++, see logs added. has explaination. 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\' quit sample.");         while (console.read() != 'q') ;       }      private static void onchangedok(object source, filesystemeventargs e)     {                     console.writeline(e.fullpath);               } 

this because iis open stream , write logs file didn't flush changes immediately. when open file in notepad++, access file trigger file modification event . please refer thread also.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -