how to set location of jvm crash log files

Persimmonium picture Persimmonium · Nov 4, 2011 · Viewed 40.4k times · Source

I need to configure where the jvm crash logs are created. I like the name they have (hs_err_pid.log) but I want them created in an specific folder.

In here you can see that you can use the

-XX:ErrorFile=./hs_err_pid<pid>.log

param to set the FILE created, but if you set this to a folder, so the file is created in that folder with the original naming convention, it does not work, it is ignored.

I have been testing this by crashing jvm 1.6 from this questions, using this: PathDasher dasher = new PathDasher(null) ;

Anybody knows a way to achieve this?

Answer

Andrey Nudko picture Andrey Nudko · Nov 4, 2011

-XX:ErrorFile=/var/log/java/hs_err_pid%p.log works.

See http://www.oracle.com/technetwork/java/javase/felog-138657.html

The parameter does not allow for environment variables, but you can use environment variables in a launcher script (e.g. .sh or .bat) and the OS will do the substitution. However, this will use the value of the environment variable at the time of starting the JVM and not when the file is written later. Furthermore, environment variables do not work when setting Run properties in Eclipse.

The JVM will not create intermediate directories saving the crash dump. The crash dump will be saved at the default location if the specified folder does not exist.