I want to periodically read a log file that is also being written to. The program will be periodically reading the log file contents and parsing it to extract some values. But I do not want to read the whole file each time.
Is there a way to read a file from a particular line onwards?
For example at the first read the file has 100 lines. I note this value and next time I read I start reading from line 100 onwards and store the line number of the current file.
Is there an efficient way to do this? The log file will grow to about 100MB and I need to read about every 5 seconds. So it wouldn't be that efficient to read the complete file each time.
Any suggestion is greatly appreciated.