java.io.FileWriter + flush()
807591May 14 2008 — edited May 15 2008I am using a FileWriter within my web app to log application events. After every write I do a flush().
The problem is the writes usually don't show up in the log file until I shutdown Tomcat. If I switch from using flush() to closing + reopening the FileWriter that fixes the issue, however that seems excessive and inefficient.
I don't mind waiting a few seconds for log messages to show up, but often the messages aren't showing up 30 minutes later, and this makes my logging near useless.
Why would flush() not do what it says? Is there a better alternative than completely closing/reopening the FileWriter? I am not using BufferedWriter or anything else. I'm using FileWriter directly.
JVM: 1.6.0_05-b13