简体   繁体   中英

Java log file parser on Windows 2008 is not able to use File.lastModified

We are using a simple log file parser written in Java. Log files are written using log4j.properties . The parser relies on File.lastModified() to pick the list of files in directory to check if there are any errors in the file.

This was working file until we moved to Windows 2008. After googling, I found file-date-modified-property-are-not-updating-while-modifying-a-file-without-closing-it that explained the behavior.

So far I am not able to find any solution to this problem. My alternate option is to store the file size each time my poller check the file and compare the current file size with the previous stored value.

Can anyone suggest a simpler idea?

Only putting it here to inform others if they face the same problem. In my case it turned out a code issue where handle to the file was not closed properly. I used Process Explorer to see any unwanted open handles to the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM