配置
报告生成的其他运行时配置可通过 process.report
的以下属性获得:
当为 true
时,reportOnFatalError
触发致命错误的诊断报告。
默认为 false
。
当为 true
时,reportOnSignal
触发信号的诊断报告。
Windows 不支持此。
默认为 false
。
当为 true
时,reportOnUncaughtException
触发未捕获异常的诊断报告。
默认为 false
。
signal
指定将用于拦截外部触发器以生成报告的 POSIX 信号标识符
默认为 'SIGUSR2'
。
filename
指定文件系统中输出文件的名称。
stdout
和 stderr
附有特殊含义。
使用这些将导致报告被写入相关的标准流。
在使用标准流的情况下,directory
中的值将被忽略。
不支持网址。
默认为包含时间戳、PID、和序列号的复合文件名。
directory
指定将写入报告的文件系统目录。
不支持网址。
默认为 Node.js 进程的当前工作目录。
// 仅触发未捕获异常上的报告。
process.report.reportOnFatalError = false;
process.report.reportOnSignal = false;
process.report.reportOnUncaughtException = true;
// 触发内部错误和外部信号的报告。
process.report.reportOnFatalError = true;
process.report.reportOnSignal = true;
process.report.reportOnUncaughtException = false;
// 将默认信号更改为 'SIGQUIT' 并启用。
process.report.reportOnFatalError = false;
process.report.reportOnUncaughtException = false;
process.report.reportOnSignal = true;
process.report.signal = 'SIGQUIT';
模块初始化的配置也可以通过环境变量获得:
NODE_OPTIONS="--report-uncaught-exception \
--report-on-fatalerror --report-on-signal \
--report-signal=SIGUSR2 --report-filename=./report.json \
--report-directory=/home/nodeuser"
具体的 API 文档可以在 process API documentation
章节下找到。
Additional runtime configuration of report generation is available via
the following properties of process.report
:
reportOnFatalError
triggers diagnostic reporting on fatal errors when true
.
Defaults to false
.
reportOnSignal
triggers diagnostic reporting on signal when true
. This is
not supported on Windows. Defaults to false
.
reportOnUncaughtException
triggers diagnostic reporting on uncaught exception
when true
. Defaults to false
.
signal
specifies the POSIX signal identifier that will be used
to intercept external triggers for report generation. Defaults to
'SIGUSR2'
.
filename
specifies the name of the output file in the file system.
Special meaning is attached to stdout
and stderr
. Usage of these
will result in report being written to the associated standard streams.
In cases where standard streams are used, the value in directory
is ignored.
URLs are not supported. Defaults to a composite filename that contains
timestamp, PID, and sequence number.
directory
specifies the file system directory where the report will be
written. URLs are not supported. Defaults to the current working directory of
the Node.js process.
// Trigger report only on uncaught exceptions.
process.report.reportOnFatalError = false;
process.report.reportOnSignal = false;
process.report.reportOnUncaughtException = true;
// Trigger report for both internal errors as well as external signal.
process.report.reportOnFatalError = true;
process.report.reportOnSignal = true;
process.report.reportOnUncaughtException = false;
// Change the default signal to 'SIGQUIT' and enable it.
process.report.reportOnFatalError = false;
process.report.reportOnUncaughtException = false;
process.report.reportOnSignal = true;
process.report.signal = 'SIGQUIT';
Configuration on module initialization is also available via environment variables:
NODE_OPTIONS="--report-uncaught-exception \
--report-on-fatalerror --report-on-signal \
--report-signal=SIGUSR2 --report-filename=./report.json \
--report-directory=/home/nodeuser"
Specific API documentation can be found under
process API documentation
section.