This section describes which server options configure the default error log destination, which can be the console or a named file. It also indicates which log sink components base their own output destination on the default destination.本节介绍哪些服务器选项配置默认错误日志目标,该目标可以是控制台或命名文件。它还指示哪些日志接收器组件将其自己的输出目标基于默认目标。
In this discussion, “console” means 在本讨论中,“console”表示标准错误输出stderr
, the standard error output. stderr
。This is your terminal or console window unless the standard error output has been redirected to a different destination.这是您的终端或控制台窗口,除非标准错误输出已重定向到其他目的地。
The server interprets options that determine the default error log destination somewhat differently for Windows and Unix systems. Be sure to configure the destination using the information appropriate to your platform. 对于Windows和Unix系统,服务器对确定默认错误日志目标的选项的解释有些不同。请确保使用适合您的平台的信息配置目的地。After the server interprets the default error log destination options, it sets the 服务器解释默认错误日志目标选项后,会设置log_error
system variable to indicate the default destination, which affects where several log sink components write error messages. The following sections address these topics.log_error
系统变量以指示默认目标,这会影响多个日志接收器组件写入错误消息的位置。以下各节介绍了这些主题。
On Windows, mysqld uses the 在Windows上,mysqld使用--log-error
, --pid-file
, and --console
options to determine whether the default error log destination is the console or a file, and, if a file, the file name:--log-error
、--pid-file
和--console
选项来确定默认错误日志目标是控制台还是文件,如果是文件,则确定文件名:
If 如果给定了--console
is given, the default destination is the console. (--console
takes precedence over --log-error
if both are given, and the following items regarding --log-error
do not apply.)--console
,则默认目标是控制台。(如果两者都给定,则--console
优先于--log-error
,并且以下关于--log-error
的项目不适用。)
If 如果没有给出--log-error
is not given, or is given without naming a file, the default destination is a file named
in the data directory, unless the host_name
.err--pid-file
option is specified. --log-error
,或者没有命名文件,则默认目标是数据目录中名为host_name.err
的文件,除非指定了--pid-file
选项。In that case, the file name is the PID file base name with a suffix of 在这种情况下,文件名是数据目录中后缀为.err
in the data directory..err
的PID文件基名称。
If 如果为文件命名时指定了--log-error
is given to name a file, the default destination is that file (with an .err
suffix added if the name has no suffix). --log-error
,则默认目标为该文件(如果名称没有后缀,则添加一个.err
后缀)。The file location is under the data directory unless an absolute path name is given to specify a different location.文件位置位于数据目录下,除非指定了绝对路径名以指定其他位置。
If the default error log destination is the console, the server sets the 如果默认的错误日志目标是控制台,则服务器会将log_error
system variable to stderr
. log_error
系统变量设置为stderr
。Otherwise, the default destination is a file and the server sets 否则,默认目标是一个文件,服务器将log_error
to the file name.log_error
设置为文件名。
On Unix and Unix-like systems, mysqld uses the 在Unix和类Unix系统上,mysqld使用--log-error
option to determine whether the default error log destination is the console or a file, and, if a file, the file name:--log-error
选项来确定默认的错误日志目标是控制台还是文件,如果是文件,则确定文件名:
If 如果没有给出--log-error
is not given, the default destination is the console.--log-error
,则默认目标是控制台。
If 如果在没有命名文件的情况下给出--log-error
is given without naming a file, the default destination is a file named
in the data directory.host_name
.err--log-err
,则默认目标是数据目录中名为host_name.err
的文件。
If 如果为文件命名时指定了--log-error
is given to name a file, the default destination is that file (with an .err
suffix added if the name has no suffix). --log-error
,则默认目标为该文件(如果名称没有后缀,则添加一个.err
后缀)。The file location is under the data directory unless an absolute path name is given to specify a different location.文件位置位于数据目录下,除非指定了绝对路径名以指定其他位置。
If 如果在使用--log-error
is given in an option file in a [mysqld]
, [server]
, or [mysqld_safe]
section, on systems that use mysqld_safe to start the server, mysqld_safe finds and uses the option, and passes it to mysqld.mysqld_safe
启动服务器的系统上,在[mysqld]
、[server]
或[mysqld_safe]
部分的选项文件中给出--log-error
,则mysqld_safe会找到并使用该选项,并将其传递给mysqld。
It is common for Yum or APT package installations to configure an error log file location under Yum或APT软件包安装通常会在服务器配置文件中使用类似/var/log
with an option like log-error=/var/log/mysqld.log
in a server configuration file. log-error=/var/log/mysqld.log
的选项在/var/log
下配置错误日志文件位置。Removing the path name from the option causes the 从选项中删除路径名会导致使用数据目录中的
file in the data directory to be used.host_name
.errhost_name.err
文件。
If the default error log destination is the console, the server sets the 如果默认的错误日志目标是控制台,则服务器会将log_error
system variable to stderr
. log_error
系统变量设置为stderr
。Otherwise, the default destination is a file and the server sets 否则,默认目标是一个文件,服务器将log_error
to the file name.log_error
设置为文件名。
After the server interprets the error log destination configuration options, it sets the 服务器解释错误日志目标配置选项后,会设置log_error
system variable to indicate the default error log destination. log_error
系统变量以指示默认的错误日志目标。Log sink components may base their own output destination on the 日志接收器组件可以基于log_error
value, or determine their destination independently of log_error
log_error
值来确定其自己的输出目的地,或者独立于log_error
来确定其目的地
If 如果log_error
is stderr
, the default error log destination is the console, and log sinks that base their output destination on the default destination also write to the console:log_error
是stderr
,则默认的错误日志目标是控制台,并且以默认目标为输出目标的日志接收器也会写入控制台:
log_sink_internal
, log_sink_json
, log_sink_test
: These sinks write to the console. This is true even for sinks such as :这些接收器写入控制台。即使对于像log_sink_json
that can be enabled multiple times; all instances write to the console.log_sink_json
这样可以多次启用的接收器也是如此;所有实例都写入控制台。
log_sink_syseventlog
: This sink writes to the system log, regardless of the :无论log_error
value.log_error
值为多少,此接收器都会写入系统日志。
If 如果log_error
is not stderr
, the default error log destination is a file and log_error
indicates the file name. log_error
不是stderr
,则默认的错误日志目标是一个文件,log_error
表示文件名。Log sinks that base their output destination on the default destination base output file naming on that file name. (A sink might use exactly that name, or it might use some variant thereof.) 日志接收器,其输出目标基于基于该文件名的默认目标基本输出文件命名。(水槽可能正是这个名字,也可能使用它的一些变体。)Suppose that the 假设log_error
value file_name
. Then log sinks use the name like this:log_error
值为file_name
。然后日志接收器使用如下名称:
log_sink_internal
, log_sink_test
: These sinks write to :这些接收器写入file_name
.file_name
。
log_sink_json
: Successive instances of this sink named in the :log_error_services
value write to files named file_name
plus a numbered .
suffix: NN
.json
, file_name
.00.json
, and so forth.file_name
.01.jsonlog_error_services
值中命名的此接收器的连续实例写入名为file_name
的文件加上编号为NN.json
的后缀:file_name.00.json
、file_name.01.json
等等。
log_sink_syseventlog
: This sink writes to the system log, regardless of the :无论log_error
value.log_error
值为多少,此接收器都会写入系统日志。