I have a log file which is updated in real time (new lines added). Reading from the Log File and loading it into a List Object is no problem.
The problem is when the file becomes 100K in size or bigger; and I need to check it every few seconds. I don't want to have to load the whole file into a list object just to get the last few added lines. With the larger size files, it can take upto 10-20 seconds to laod the entire file.
Is there a way I can just read the last X amount of lines of a file. It doesn't even matter if some of them were read previously. For example, the last 50 lines, or the last 10 lines of a file. Even the last 1 line.
Assuming the file is just plain text - how would one accomplish this?
Look forward to any ideas you may have! All replies very much appreciated.