# How to enable GC Logs?
You can enable GC logging by passing the following JVM arguments to your application start-up script.
Until Java 8:
If your application is running on Java 8 or below version, pass below JVM arguments:
-XX:+PrintGCDetails -Xloggc:<gc-log-file-path>
Example:
-XX:+PrintGCDetails -Xloggc:/opt/tmp/myapp-gc.log
1
2
3
4
5
2
3
4
5
From Java 9:
If your application is running on Java 9 or above version, pass the below JVM arguments:
-Xlog:gc*:file=<gc-log-file-path>
Example:
-Xlog:gc*:file=/opt/tmp/myapp-gc.log
1
2
3
4
5
2
3
4
5
Note: Enabling GC Logging adds no noticeable overhead to your application. Here is a study (opens new window) on the overhead added by GC logging.