简体   繁体   中英

What does Java.util.logging do when its FileHandler cannot write to the file?

I've written software that uses Java.util.logging. It runs on a client PC. I'm using a FileHandler to log certain entries to a file. The file resides on on a server. If the server goes away for a bit, then returns (or some other temporary error occurs), what does FileHandler do?

I occasionally see scenarios in which log records have failed to get written to the file (for hours or days). I need to stop/start the software to restart the logging. I'm hoping that there is a way to recover from a "temporary" file problem, whether it's provided by the class, or if it's something I need to code for.

Note: I'm using Java 1.4.2 (wince) because I'm using a proprietary operating system on proprietary hardware. It is what it is!

The FileHandler uses the java.io.FileOutputStream to write log records. If a write fails then the FileHandler will fallback to using the assigned ErrorManager . The default ErrorManager will just write the first failure to the console and ignore all errors after that. If you want to change that behavior you have to install a custom ErrorManager.

Since you are on proprietary operating system on proprietary hardware you should just mock up a test case using a FileOutputStream or FileHandler and simulate the error conditions.

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