Im reading a log file in Java on a Linux box on a continual schedule of 2 minutes looking for certain messages. I store the last offset (RandomAccessFile getFilePointer) and read from it onwards when I detect LastModified has changed; is this best practice or even right?
Tell me more
×
Programmers Stack Exchange is a question and answer site for
professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
|
|
Assuming the following:
You shouldn't have much to worry about. Just remember to close the file after reading it and to open it with "r" mode only. |
|||
|
|
|
If it works, then it's good enough. The only problems I see with this solution is two-fold:
The first point is a bit of a stretch since it is a bad idea to edit a log file (as users are only supposed to append to the file). Second point is a common practice, that the log file is split in dates or at some amount of lines. |
|||
|
