8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

7.5.3 错误日志组件7.5.3 Error Log Components

本节描述了单个错误日志组件的特性。有关注意配置错误日志的一般信息,请参见 第 7.4.2 节,“错误日志”。This section describes the characteristics of individual error log components. For general information about configuring error logging, see Section 7.4.2, “The Error Log”.

日志组件可以是过滤器或接收器:A log component can be a filter or a sink:

  • 过滤器处理日志事件,以添加、删除或修改事件字段,或完全删除事件。处理后的事件会传递给启用组件列表中的下一个日志组件。A filter processes log events, to add, remove, or modify event fields, or to delete events entirely. The resulting events pass to the next log component in the list of enabled components.

  • 接收器是日志事件的目标(写入器)。通常,接收器会将日志事件处理成具有特定格式的日志消息,并将这些消息写入其关联的输出,例如文件或系统日志。接收器也可以写入 Performance Schema 的 error_log 表;见 第 29.12.22.2 节,“error_log 表”。事件会毫无修改地传递给已启用组件列表中的下一个日志组件(也就是说,虽然接收器会格式化事件以生成输出消息,但在事件内部传递给下一个组件时不会修改事件)。A sink is a destination (writer) for log events. Typically, a sink processes log events into log messages that have a particular format and writes these messages to its associated output, such as a file or the system log. A sink may also write to the Performance Schema error_log table; see Section 29.12.22.2, “The error_log Table”. Events pass unmodified to the next log component in the list of enabled components (that is, although a sink formats events to produce output messages, it does not modify events as they pass internally to the next component).

log_error_services 系统变量列出了已启用的日志组件。列表中未命名的组件将被禁用。log_error_services 还会隐式加载尚未加载的错误日志组件。有关更多信息,请参见 第 7.4.2.1 节,“错误日志配置”。The log_error_services system variable lists the enabled log components. Components not named in the list are disabled. log_error_services also implicitly loads error log components if they are not already loaded. For more information, see Section 7.4.2.1, “Error Log Configuration”.

以下部分描述了按组件类型分组的各个日志组件:The following sections describe individual log components, grouped by component type:

组件描述包括以下类型的信息:Component descriptions include these types of information:

  • 组件名称及其预期用途。The component name and intended purpose.

  • 组件是内置的还是必须加载的。对于可加载组件,描述会指定在使用 INSTALL COMPONENT 和 UNINSTALL COMPONENT 语句显式加载或卸载组件时要使用的 URN。隐式加载错误日志组件仅需组件名称。更多信息,请参见 第 7.4.2.1 节,“错误日志配置”。Whether the component is built in or must be loaded. For a loadable component, the description specifies the URN to use if explicitly loading or unloading the component with the INSTALL COMPONENT and UNINSTALL COMPONENT statements. Implicitly loading error log components requires only the component name. For more information, see Section 7.4.2.1, “Error Log Configuration”.

  • 组件是否可以在 log_error_services 值中列出多次。Whether the component can be listed multiple times in the log_error_services value.

  • 对于汇组件,组件写入输出的目标。For a sink component, the destination to which the component writes output.

  • 对于一个接收器组件,它是否支持 Performance Schema error_log 表的接口。For a sink component, whether it supports an interface to the Performance Schema error_log table.

过滤错误日志组件Filter Error Log Components

错误日志过滤组件用于实现错误日志事件的过滤。如果没有启用任何过滤组件,则不会进行任何过滤。Error log filter components implement filtering of error log events. If no filter component is enabled, no filtering occurs.

任何启用的过滤器组件仅影响 log_error_services 值中后列出的组件的日志事件。特别是,对于在任何过滤器组件之前列在 log_error_services 中的任何日志接收组件,不会发生任何日志事件过滤。Any enabled filter component affects log events only for components listed later in the log_error_services value. In particular, for any log sink component listed in log_error_services earlier than any filter component, no log event filtering occurs.

log_filter_internal 组件The log_filter_internal Component

如果 log_filter_internal 被禁用,log_error_verbosity 和 log_error_suppression_list 不会生效。If log_filter_internal is disabled, log_error_verbosity and log_error_suppression_list have no effect.

log_filter_dragnet 组件The log_filter_dragnet Component

接收器错误日志组件Sink Error Log Components

错误日志接收组件是实现错误日志输出的写入器。如果没有启用接收组件,则不会产生日志输出。Error log sink components are writers that implement error log output. If no sink component is enabled, no log output occurs.

一些接收器组件描述提到默认错误日志的目标。这个目标可以是控制台或文件,其由 log_error 系统变量的值指示,其确定方式如 第 7.4.2.2 节,“默认错误日志目标配置” 所述。Some sink component descriptions refer to the default error log destination. This is the console or a file and is indicated by the value of the log_error system variable, determined as described in Section 7.4.2.2, “Default Error Log Destination Configuration”.

log_sink_internal 组件The log_sink_internal Component
  • 目的:实现传统错误日志消息输出格式。Purpose: Implements traditional error log message output format.

  • URN:此组件是内置的,无需加载。URN: This component is built in and need not be loaded.

  • 允许多次使用:否。Multiple uses permitted: No.

  • 输出目标:写入默认错误日志目标。Output destination: Writes to the default error log destination.

  • 性能模式支持:写入 error_log 表。提供用于读取之前服务器实例创建的错误日志文件的解析器。Performance Schema support: Writes to the error_log table. Provides a parser for reading error log files created by previous server instances.

log_sink_json 组件The log_sink_json Component
  • 用途:实现 JSON 格式的错误日志记录。参见 第 7.4.2.7 节,“JSON 格式的错误日志记录”。Purpose: Implements JSON-format error logging. See Section 7.4.2.7, “Error Logging in JSON Format”.

  • 统一资源名称:file://component_log_sink_jsonURN: file://component_log_sink_json

  • 允许多次使用:是的。Multiple uses permitted: Yes.

  • 输出目标:此接收器根据默认错误日志目标确定其输出目标,该目标由 log_error 系统变量提供:Output destination: This sink determines its output destination based on the default error log destination, which is given by the log_error system variable:

    • 如果 log_error 指定了一个文件,则接收器的输出文件命名将基于该文件名,加上一个编号的 .NN.json 后缀,其中 NN 从 00 开始。例如,如果 log_error 是 file_name,则在 log_error_services 中命名的连续 log_sink_json 实例将写入 file_name.00.json、file_name.01.json,依此类推。If log_error names a file, the sink bases output file naming on that file name, plus a numbered .NN.json suffix, with NN starting at 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, file_name.01.json, and so forth.

    • 如果 log_error 是 stderr,则接收器会写入控制台。如果 log_sink_json 在 log_error_services 值中被多次命名,它们都将写入控制台,这可能没有什么用处。If log_error is stderr, the sink writes to the console. 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.

  • 性能模式支持:写入 error_log 表。提供用于读取之前服务器实例创建的错误日志文件的解析器。Performance Schema support: Writes to the error_log table. Provides a parser for reading error log files created by previous server instances.

log_sink_syseventlog 组件The log_sink_syseventlog Component
  • 目的:实现错误记录到系统日志。在 Windows 上这是事件日志,在 Unix 和类 Unix 系统上是 syslog。参见 第 7.4.2.8 节,“将错误记录到系统日志”。Purpose: Implements error logging to the system log. This is the Event Log on Windows, and syslog on Unix and Unix-like systems. See Section 7.4.2.8, “Error Logging to the System Log”.

  • 统一资源名称:file://component_log_sink_syseventlogURN: file://component_log_sink_syseventlog

  • 允许多次使用:否。Multiple uses permitted: No.

  • 输出目标:写入系统日志。不使用默认的错误日志目标。Output destination: Writes to the system log. Does not use the default error log destination.

  • 性能模式支持:不写入 error_log 表。未提供用于读取以前服务器实例创建的错误日志文件的解析器。Performance Schema support: Does not write to the error_log table. Does not provide a parser for reading error log files created by previous server instances.

log_sink_test 组件The log_sink_test Component
  • 目的:仅供内部编写测试用例使用,不用于生产环境。Purpose: Intended for internal use in writing test cases, not for production use.

  • 统一资源名称(URN):file://component_log_sink_testURN: file://component_log_sink_test

对于log_sink_test,未指定接收器属性,例如是否允许多次使用以及输出目标,因为如前所述,它仅用于内部使用。因此,其行为可能随时发生变化。Sink properties such as whether multiple uses are permitted and the output destination are not specified for log_sink_test because, as mentioned, it is for internal use. As such, its behavior is subject to change at any time.