Is it possible to specify where JVM's crash dumps go?
Asked Answered
L

2

13

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?

Lefebvre answered 10/12, 2009 at 10:49 Comment(1)
Btw, using everything (voidtools.com) to search files by name is very handy on windows.Kohn
D
17

Joonas,

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.

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

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

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

Doodlebug answered 3/5, 2012 at 15:24 Comment(2)
how to run Java with this option? I couldn't do that through cmdEagan
@MuhammedRefaat On console: java -XX:ErrorFile=/path/to/file.log -jar myapp.jarFortunio
S
7

By default the heap dump is created in a file called java_pidpid.hprof in the working directory of the VM. You can specify an alternative file name or directory with the -XX:HeapDumpPath= option. For example -XX:HeapDumpPath=/disk2/dumps will cause the heap dump to be generated in the /disk2/dumps directory.

Seedling answered 10/12, 2009 at 10:58 Comment(1)
-1 Question is about crash log, not heap dump as the accepted answer points out. This is still good info but not an answer for this question.Penzance

© 2022 - 2024 — McMap. All rights reserved.