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?
Parsing a Log File - Java
java;performance
Assuming the following:this log file is only appended toyou're prepared to meet the possibility that the file no longer exists / shorter than your current offsetprogram writing to log wouldn't attempt to delete the log file (since you may be reading it at the time) or that it handles such situations wellYou shouldn't have much to worry about.  Just remember to close the file after reading it and to open it with r mode only.