A JVM option is a configuration argument that changes how the Java Virtual Machine runs. For GC troubleshooting, use one to enable logging and direct events into a separate file instead of a crowded terminal. section 11.2
Use JVM options to make runtime behavior observable and investigation practical:
- Choose a writable destination for the GC-log file. section 11.2
- Add time, uptime, level, and tags so each event has useful context. section 11.2
- Review the resulting file with a specialized analyzer when pauses, memory spikes, or high CPU usage need investigation. section 11.0 section 11.2
Store GC logs during application startup
Run `java -Xlog:gc*:file=gc.log:time,uptime,level,tags -jar yourApp.jar`. After the application runs, inspect `gc.log`; it contains formatted GC events that can be retained, shared, filtered, or uploaded for analysis. section 11.2
-Xlog:gc*:file=<file_path>:time,uptime,level,tags
The option’s structure makes the destination and four diagnostic fields explicit. section 11.2
