To specify where the log file will be created, use the product flag -XX:ErrorFile=
file, where file represents the full path for the log file location. The substring %%
in the file variable is converted to %
, and the substring %p
is converted to the PID of the process.
In the following example, the error log file will be written to the directory /var/log/java and will be named java_errorpid.log:
java -XX:ErrorFile=/var/log/java/java_error%p.log
If the -XX:ErrorFile=file
flag is not specified, the default log file name is hs_err_pid.log, where pid is the PID of the process.
In addition, if the -XX:ErrorFile=file
flag is not specified, the system attempts to create the file in the working directory of the process. In the event that the file cannot be created in the working directory (insufficient space, permission problem, or other issue), the file is created in the temporary directory for the operating system. On Oracle Solaris and Linux operating systems the temporary directory is /tmp. On Windows the temporary directory is specified by the value of the TMP
environment variable; if that environment variable is not defined, the value of the TEMP
environment variable is used.