|P is for Practical
Re: Extract new lines from log fileby ferreira (Chaplain)
|on Jan 02, 2007 at 20:00 UTC
Is there a better way to periodically extract the new lines from a log file?
I did it once and the algorithm was very similar to the one you described. The only thing that changed was that instead of saving the line count, I save the return of tell (that is, the offset of the file at the last read). This way, when you decide the file has changed and read the offset where you stopped, you just seek and go on from that place. I think you're gonna be quite pleased with the performance after this straightforward change.