Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to retrieve JVM crash logs from a runtime container #403

Open
dmikusa opened this issue Jun 19, 2024 · 1 comment
Open

Document how to retrieve JVM crash logs from a runtime container #403

dmikusa opened this issue Jun 19, 2024 · 1 comment
Labels
type:enhancement A general enhancement

Comments

@dmikusa
Copy link
Contributor

dmikusa commented Jun 19, 2024

Describe the Enhancement

At runtime, if the JVM crashes, it will generate JVM crash logs that provide details about why it crashed. These logs get written to a directory that is inside the container and no longer available after the container crashes. This is no fun because you can't figure out why the JVM crashed.

Possible Solution

If your JVM is crashing, what you can do is this:

  1. When you run your container, attach a volume mount to some arbitrary and presently unused location, like /jvm-crashes.
  2. Set JAVA_TOOL_OPTIONS to include the -XX:ErrorFile=/jvm-crashes/hs_err_<my-app>.log (replace <my-app> with something to identify your app).
  3. Restart your application container.

When it crashes next, it will write the file to the volume mount and you can retrieve it from there.

Two notes of caution:

  1. If you have multiple instances of your container and you mount the same volume to all of them, they will all try to write crash logs to the same location. There's no way presently to insert a unique identifier into the path/filename to prevent this type of collision. This is unlikely to cause problems, but if you have multiple instances that crash at the same time, only one of the files is going to end up on the volume mount (or maybe you get some weird mix of both).

  2. If your application crashes multiple times, you're only going to see the most recent crash log file. Again, there's no unique identifier or date/timestamp in the file name so as it crashes over and over, it will just overwrite the previous crash logs.

Motivation

Being able to see debug logs in important.

@dmikusa dmikusa added the type:enhancement A general enhancement label Jun 19, 2024
@anthonydahanne
Copy link
Member

what about -XX:ErrorFileRedirect to stdout?

https://bugs.openjdk.org/browse/JDK-8220786

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants