How to monitor a log file in Windows and trigger an email/action?

in #computer8 years ago

I've been looking around for something that does the following:
monitors last line of a log file for a string (tailing)
upon finding the string sends an email
(optional) calls a batch file (stop service/deleted some files/start service)
I can't seem to find a good solution for this
tail for windows is really slow and eats up cpu
powershell "get-content -path $path -tail 1 -wait" seems to only work once the content is written to disk or something, my testing it grabs the initial line but any subsequent lines added never appear, so I'm not sure
I'm open to making my own standalone exe in c# or vb.net or something if there are good working examples out there but I can't find anything.
My logs files are log4j and roll over so the blah.log is always the latest log data, i need to check each line that gets appended for a string.