This section describes how to configure error logging using the built-in filter, 本节介绍如何使用内置筛选器log_filter_internal, and the JSON sink, log_sink_json, to take effect immediately and for subsequent server startups. log_filter_internal和JSON接收器log_sink_json配置错误日志记录,以便立即生效并用于后续服务器启动。For general information about configuring error logging, see Section 5.4.2.1, “Error Log Configuration”.有关配置错误日志的一般信息,请参阅第5.4.2.1节,“错误日志配置”。
To enable the JSON sink, first load the sink component, then modify the 要启用JSON接收器,请首先加载接收器组件,然后修改log_error_services value:log_error_services值:
INSTALL COMPONENT 'file://component_log_sink_json'; SET PERSIST log_error_services = 'log_filter_internal; log_sink_json';
To set 要将log_error_services to take effect at server startup, use the instructions at Section 5.4.2.1, “Error Log Configuration”. log_error_services设置为在服务器启动时生效,请使用第5.4.2.1节,“错误日志配置”中的说明。Those instructions apply to other error-logging system variables as well.这些说明也适用于其他错误记录系统变量。
It is permitted to name 允许在log_sink_json multiple times in the log_error_services value. log_error_services值中多次命名log_sink_json。For example, to write unfiltered events with one instance and filtered events with another instance, you could set 例如,要用一个实例编写未筛选的事件,用另一个实例写入已筛选的事件。您可以这样设置log_error_services like this:log_error_services:
SET PERSIST log_error_services = 'log_sink_json; log_filter_internal; log_sink_json';
The JSON sink determines its output destination based on the default error log destination, which is given by the JSON接收器根据log_error system variable. log_error系统变量给定的默认错误日志目的地来确定其输出目的地。If 如果log_error names a file, the JSON sink bases output file naming on that file name, plus a numbered . suffix, with NN.jsonNN starting at 00. log_error命名一个文件,JSON接收器会根据该文件名加上编号的NN.json后缀来命名输出文件,NN从00开始。For example, if 例如,如果log_error is file_name, successive instances of log_sink_json named in the log_error_services value write to , file_name.00.json, and so forth.file_name.01.jsonlog_error为file_name,则log_error_services值中命名的log_sink_json的连续实例将写入file_name.00.json、file_name.01.json等。
If 如果log_error is stderr, the JSON sink writes to the console. log_error是stderr,JSON接收器将写入控制台。If 如果在log_sink_json is named multiple times in the log_error_services value, they all write to the console, which is likely not useful.log_error_services值中多次命名log_sink_json,那么它们都会写入控制台,这可能没有用处。