Java: how to specify JVM -XX: ErrorFile argument and save automatic PID in file name

I use JNI, and when a crash occurs due to errors in the target application, the hs_err_pid * .log file is created. I want to change the default location where this file is stored. Now from the search, I understand that this can be achieved with the JVM -XX: ErrorFile argument.

The documentation states that the default value for this parameter is equal. / hs _err_pid <pid >.log

Now that I am overriding the default value, how can I tell the JVM to still contain the process id in the file name? I obviously tried to literally set targetDir / hs_err_pid <pid >.log as a command line parameter, but this led to ignoring the entire argument (and the file stored in the default location, i.e. in the working directory), if I only say targetDir / hs_err_pid .log, the file is stored where I want, but does not get the process identifier added to the file name.

Any suggestions would be appreciated.

+4
source share
2 answers

Try

-XX:ErrorFile=targetDir/hs_err_pid_%p.log
+6
source

On Windows:

-XX:ErrorFile=C:\targetDir\hs_err_pid_%%p.log
-1
source

Source: https://habr.com/ru/post/1533216/


All Articles