How to Trace JVM Filesystem Accesses Using Java

For tracing filesystem accesses of Java applications, native tracing facilities are always the first choice. On Windows, use Process Monitor to trace I/O. On Linux, use strace. Other platforms provide similar facilities.

By tracing directly in Java, you can work around environment limitations. For example, strace is unavailable in a container that lacks the CAP_SYS_PTRACE capability and the container host is not always accessible. Also, a potentially lighter-weight tracing mechanism comes handy for tracing in production environments.