5.4.2.8 Error Logging to the System Log错误记录到系统日志

It is possible to have mysqld write the error log to the system log (the Event Log on Windows, and syslog on Unix and Unix-like systems).可以让mysqld将错误日志写入系统日志(在Windows上为事件日志,在Unix和类Unix系统上为系统日志)。

This section describes how to configure error logging using the built-in filter, log_filter_internal, and the system log sink, log_sink_syseventlog, to take effect immediately and for subsequent server startups. 本节介绍如何使用内置筛选器log_filter_internal和系统日志接收器log_sink_syseventlog配置错误日志记录,使其立即生效并用于后续服务器启动。For general information about configuring error logging, see Section 5.4.2.1, “Error Log Configuration”.有关配置错误日志的一般信息,请参阅第5.4.2.1节,“错误日志配置”

To enable the system log sink, first load the sink component, then modify the log_error_services value:要启用系统日志接收器,请首先加载接收器组件,然后修改log_error_services值:

INSTALL COMPONENT 'file://component_log_sink_syseventlog';
SET PERSIST log_error_services = 'log_filter_internal; log_sink_syseventlog';

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.这些说明也适用于其他错误记录系统变量。

Note注意

For MySQL 8.0 configuration, you must enable error logging to the system log explicitly. This differs from MySQL 5.7 and earlier, for which error logging to the system log is enabled by default on Windows, and on all platforms requires no component loading.对于MySQL 8.0配置,必须显式启用对系统日志的错误日志记录。这与MySQL 5.7及更早版本不同,在Windows上默认启用将错误记录到系统日志,并且在所有平台上都不需要加载组件。

Error logging to the system log may require additional system configuration. Consult the system log documentation for your platform.将错误日志记录到系统日志可能需要额外的系统配置。请参阅您的平台的系统日志文档。

On Windows, error messages written to the Event Log within the Application log have these characteristics:在Windows上,写入应用程序日志中的事件日志的错误消息具有以下特征:

On Unix and Unix-like systems, logging to the system log uses syslog. The following system variables affect syslog messages:在Unix和类Unix系统上,登录到系统日志使用syslog。以下系统变量会影响syslog消息:

Note注意

Prior to MySQL 8.0.13, use the log_syslog_facility, log_syslog_include_pid, and log_syslog_tag system variables rather than the syseventlog.xxx variables.在MySQL 8.0.13之前,请使用log_syslog_facilitylog_syslog_include_pidlog_syslog_tag系统变量,而不是syseventlog.xxx变量。

MySQL uses the custom label System for important system messages about non-error situations, such as startup, shutdown, and some significant changes to settings. MySQL将自定义标签“System”用于有关非错误情况的重要系统消息,如启动、关闭和一些重大的设置更改。In logs that do not support custom labels, including the Event Log on Windows, and syslog on Unix and Unix-like systems, system messages are assigned the label used for the information priority level. 在不支持自定义标签的日志中,包括Windows上的事件日志以及Unix和类Unix系统上的syslog,系统消息被分配用于信息优先级的标签。However, these messages are printed to the log even if the MySQL log_error_verbosity setting normally excludes messages at the information level.但是,即使MySQL log_error_verbosity设置通常在信息级别排除消息,这些消息也会打印到日志中。

When a log sink must fall back to a label of Information instead of System in this way, and the log event is further processed outside of the MySQL server (for example, filtered or forwarded by a syslog configuration), these events may by default be processed by the secondary application as being of Information priority rather than System priority.当日志接收器必须以这种方式返回到“Information”(信息)而不是“System”(系统)标签,并且日志事件在MySQL服务器之外进行进一步处理(例如,通过syslog配置进行筛选或转发)时,默认情况下,辅助应用程序可能会将这些事件处理为“Information”优先级,而不是“System”优先级。