gc-logging.asciidoc 2.0 KB

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