Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8220787

Create new switch to redirect error reporting output to stdout or stderr



    • behavioral
    • minimal
    • The risk for existing installations is minimal. The introduction of these new switches will not affect existing installations which do not use them.
    • add/remove/modify command line option
    • JDK



      Add two new switches to redirect error reporting output to stdout or stderr, respectively.


      In certain container environments the local file system is ephemeral - its content does not survive the death of the container. In those environments post-mortem analyzing crashes can be challenging because core files and hs-err files are lost.

      Since stdout and stderr of the VM process are usually catched in some sort of logging system, hs-err files could be written to stdout or stderr instead, increasing chances of meaningful post-mortem analysis.


      Two new switches are added which, when specified, redirect the content that would have normally written to the hs-err file to stdout or stderr instead.


      Two new boolean switches are proposed, "ErrorFileToStdout" and "ErrorFileToStderr", respectively. If specified, if a fatal error occurs which normally would result in an hs-err file written to the file system, the content of that hs-err file would be written to stdout or stderr instead.

      If both "ErrorFileToStdout" and "ErrorFileToStderr" are specified on the command line, the switch specified last overrides the prior switch.

      If specified in conjunction with -XX:ErrorFile, -XX:ErrorFile will be ignored.

      +  product(bool, ErrorFileToStdout, false,                                   \
      +          "If specified, error data will be written to stdout.")            \
      +                                                                            \
      +  product(bool, ErrorFileToStderr, false,                                   \
      +          "If specified, error data will be written to stderr.")            \
      +                                                                            \


      Post Mortem error data come in two parts: a first, abbreviated section (the '#' section) is always dumped to stdout. A second, full report usually goes to the error file (default name hs_err...).

      This proposal only concerns the second part and does not affect the first part. We will continue to print out the abbreviated report to stdout first, unless ErrorFileToStdout is given (so both parts are to be printed to stdout), in which case the first part is suppressed to avoid redundant information.

      Alternatives considered and rejected:

      a) We briefly considered reusing the ErrorFile switch, giving it two special values for stdout, stderr respectively, e.g."-XX:ErrorFile=(STDOUT|STDERR)". Two problems with that: - Existing installations may already use this value, expecting post mortem files with that name - Accidentally using this form on a VM which is too old would create a file with that name where one would expect output to stdout, stderr Compounded are these points by the fact that one only will notice something is wrong when the VM crashes, not before.

      b) An alternative form of "-XX:ErrorFileRedirectTo=(STDOUT|STDERR)" was proposed, which would have resulted in one one, not two switches. This was rejected because -XX:+ErrorFileToStderr/ToStdout is more in line with existing switches DisplayVMOutputToStderr/Out.


        Issue Links



              stuefe Thomas Stuefe
              stuefe Thomas Stuefe
              Aleksey Shipilev, David Holmes
              0 Vote for this issue
              4 Start watching this issue