Event-Based Interface to Log Files

Started by
0 comments, last by kSquared 18 years, 7 months ago
Heres the situation: I have a program P, that creates and writes to a log file while it is running. I want to be able interface with this log in such a way that a new line in the file will feed into my application, which pretty much just sits there and waits for certain events to occur. This sounds like a job for ports on unix, but I am on Windows and I am not that familiar with them, much less how to port file writing on a specific file (i am not aware of P writing to multiple files, but it is a windows application and it doesnt have any console output. So my next thought is to just read from the file via i/o routines. I haven't tested this at all yet (mainly because I don't have access to my development system at the moment) but I am trying to plan ahead a bit. My first guess is that I can pretty much can have an infinite loop of line reading, and at times I will hit EOF but when the P appends a new line it will read that in still. Seems simple enough to me, but the fact that I don't know much about Windows "behind the scenes" and that I have never done anything like this worries me just a bit, so I am expecting the worst. Does anyone have any advice / info on this particular situation?
Advertisement
It wasn't clear whether you actually control the interface to P. Is P your own program or someone else's?

I'll assume it's not yours. In that case, one solution under Windows is to use a .NET language like C#, then create a FileSystemWatcher that monitors the file in question, then monitor the OnChanged event.
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}

This topic is closed to new replies.

Advertisement