|
1 | 1 | [[gc-logging]]
|
2 | 2 | === GC logging
|
3 | 3 |
|
4 |
| -By default, Elasticsearch enables GC logs. These are configured in |
5 |
| -<<jvm-options,`jvm.options`>> and default to the same default location as the |
6 |
| -Elasticsearch logs. The default configuration rotates the logs every 64 MB and |
| 4 | +By default, {es} enables GC logs. These are configured in |
| 5 | +<<jvm-options,`jvm.options`>> and output to the same default location as |
| 6 | +the {es} logs. The default configuration rotates the logs every 64 MB and |
7 | 7 | can consume up to 2 GB of disk space.
|
| 8 | + |
| 9 | +You can reconfigure JVM logging using the command line options described in |
| 10 | +https://openjdk.java.net/jeps/158[JEP 158: Unified JVM Logging]. Unless you |
| 11 | +change the default `jvm.options` file directly, the {es} default |
| 12 | +configuration is applied in addition to your own settings. To disable the |
| 13 | +default configuration, first disable logging by supplying the |
| 14 | +`-Xlog:disable` option, then supply your own command line options. This |
| 15 | +disables __all__ JVM logging, so be sure to review the available options |
| 16 | +and enable everything that you require. |
| 17 | + |
| 18 | +To see further options not contained in the original JEP, see |
| 19 | +https://docs.oracle.com/en/java/javase/13/docs/specs/man/java.html#enable-logging-with-the-jvm-unified-logging-framework[Enable |
| 20 | +Logging with the JVM Unified Logging Framework]. |
| 21 | + |
| 22 | +==== Examples |
| 23 | + |
| 24 | +* Change the default GC log output location to `/opt/my-app/gc.log` by |
| 25 | + creating `$ES_HOME/config/jvm.options.d/gc.options` with some sample |
| 26 | + options: |
| 27 | ++ |
| 28 | +[source,shell] |
| 29 | +-------------------------------------------- |
| 30 | +# Turn off all previous logging configuratons |
| 31 | +-Xlog:disable |
| 32 | +
|
| 33 | +# Default settings from JEP 158, but with `utctime` instead of `uptime` to match the next line |
| 34 | +-Xlog:all=warning:stderr:utctime,level,tags |
| 35 | +
|
| 36 | +# Enable GC logging to a custom location with a variety of options |
| 37 | +-Xlog:gc*,gc+age=trace,safepoint:file=/opt/my-app/gc.log:utctime,pid,tags:filecount=32,filesize=64m |
| 38 | +-------------------------------------------- |
| 39 | + |
| 40 | +* Configure an {es} <<docker,Docker container>> to send GC debug logs to |
| 41 | + standard error (`stderr`). This lets the container orchestrator |
| 42 | + handle the output. If using the `ES_JAVA_OPTS` environment variable, |
| 43 | + specify: |
| 44 | ++ |
| 45 | +[source,sh] |
| 46 | +-------------------------------------------- |
| 47 | +MY_OPTS="-Xlog:disable -Xlog:all=warning:stderr:utctime,level,tags -Xlog:gc=debug:stderr:utctime" |
| 48 | +docker run -e ES_JAVA_OPTS="$MY_OPTS" # etc |
| 49 | +-------------------------------------------- |
0 commit comments