是否可以指定 JVM 的故障转储去哪里?

2022-01-16 00:00:00 logging jvm java crash-dumps

我们有一个使用 JNI 的桌面应用程序,它偶尔会导致 JVM 崩溃.幸运的是,JVM 生成了一个 hs_err_pidXXXX.log 文件,该文件在调试此类错误时非常有用.但是,它似乎总是进入当前工作目录,从那里挖掘它很烦人,因为我们的其他日志文件都转到特定的日志文件位置".

We have a desktop application using JNI that occasionally causes the JVM to crash. Luckily the JVM produces a hs_err_pidXXXX.log file, which is quite useful in debugging such errors. However, it always seems to go to the current working directory, and it's annoying to dig it from there, since our other log files all go to a specific "log file place".

是否可以为这些故障转储"文件指定不同的位置?怎么样?

Is it possible to specify different location for those "crash dump" files? How?

推荐答案

Joonas,

虽然 HeapDumpPath 适用于堆转储,但它不是您问题的答案.堆转储和 jvm 崩溃日志是两个不同的东西.

Although the HeapDumpPath works for the heap dump it is not the answer for your question. The heap dump and the jvm crash log are two separate things.

要更改 jvm 崩溃日志的目的地,请使用此选项运行 java:

To change the destination of the jvm crash log run java with this option:

-XX:ErrorFile=/path/to/file.

Path/to/file 是您希望 JVM 崩溃日志输出的位置.

Path/to/file is the place you want the JVM crash log to output.

相关文章