It is possible to have mysqld write the error log to the system log (the Event Log on Windows, and 可以让mysqld将错误日志写入系统日志(在Windows上为事件日志,在Unix和类Unix系统上为系统日志)。syslog
on Unix and Unix-like systems).
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.这些说明也适用于其他错误记录系统变量。
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上,写入应用程序日志中的事件日志的错误消息具有以下特征:
Entries marked as 标记为Error
, Warning
, and Note
are written to the Event Log, but not messages such as information statements from individual storage engines.Error
、Warning
和Note
的条目会写入事件日志,但不会写入来自各个存储引擎的信息语句等消息。
Event Log entries have a source of 事件日志条目具有MySQL
(or MySQL-
if tag
syseventlog.tag
is defined as tag
).MySQL
源(如果syseventlog.tag
定义为标记,则为MySQL-tag
)。
On Unix and Unix-like systems, logging to the system log uses 在Unix和类Unix系统上,登录到系统日志使用syslog
. The following system variables affect syslog
messages:syslog
。以下系统变量会影响syslog
消息:
syseventlog.facility
: The default facility for :syslog
messages is daemon
. Set this variable to specify a different facility.syslog
消息的默认功能是daemon
。设置此变量以指定其他设施。
syseventlog.include_pid
: Whether to include the server process ID in each line of :是否在syslog
output.syslog
输出的每一行中包含服务器进程ID。
syseventlog.tag
: This variable defines a tag to add to the server identifier (:此变量定义了一个标记,用于添加到mysqld
) in syslog
messages. syslog
消息中的服务器标识符(mysqld
)中。If defined, the tag is appended to the identifier with a leading hyphen.如果已定义,则标记会用前导连字符附加到标识符上。
Prior to MySQL 8.0.13, use the 在MySQL 8.0.13之前,请使用log_syslog_facility
, log_syslog_include_pid
, and log_syslog_tag
system variables rather than the syseventlog.
variables.xxx
log_syslog_facility
、log_syslog_include_pid
和log_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 在不支持自定义标签的日志中,包括Windows上的事件日志以及Unix和类Unix系统上的syslog
on Unix and Unix-like systems, system messages are assigned the label used for the information priority level. syslog
,系统消息被分配用于信息优先级的标签。However, these messages are printed to the log even if the MySQL 但是,即使MySQL log_error_verbosity
setting normally excludes messages at the information level.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 当日志接收器必须以这种方式返回到“Information”(信息)而不是“System”(系统)标签,并且日志事件在MySQL服务器之外进行进一步处理(例如,通过syslog配置进行筛选或转发)时,默认情况下,辅助应用程序可能会将这些事件处理为“Information”优先级,而不是“System”优先级。syslog
configuration), these events may by default be processed by the secondary application as being of “Information” priority rather than “System” priority.