Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set location of jvm crash log files

Tags:

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?

like image 230
Persimmonium Avatar asked Nov 04 '11 11:11

Persimmonium


People also ask

Where are JVM crash logs?

JVM crash log files are named hs_err_pid*. log, with the process id of the JVM that crashed, and are placed in the Micro-Manager folder.

What is the default log file path for JVM?

The default location for files is your working directory. Console if its System. err or System.

What happens when JVM crashes?

When the JRockit JVM crashes, it generates a binary crash file ( . core or . mdmp ). By default, the binary crash file contains a copy of the entire JVM process.

How do I trigger a JVM crash?

To crash a JVM, aside from JNI, you need to find a bug in the VM itself. An infinite loop just consumes CPU. Infinitely allocating memory should just cause OutOfMemoryError's in a well built JVM. This would probably cause problems for other threads, but a good JVM still should not crash.


2 Answers

-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.

like image 91
Andrey Nudko Avatar answered Sep 20 '22 14:09

Andrey Nudko


You have to use this as

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

in command prompt. Here, Crash is my java file.

like image 43
user4886120 Avatar answered Sep 20 '22 14:09

user4886120