5.4.2.2 Default Error Log Destination Configuration默认错误日志目标配置

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 stderr, the standard error output. 在本讨论中,“console”表示标准错误输出stderrThis 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系统变量以指示默认目标,这会影响多个日志接收器组件写入错误消息的位置。以下各节介绍了这些主题。

Default Error Log Destination on WindowsWindows上的默认错误日志目标

On Windows, mysqld uses the --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:在Windows上,mysqld使用--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 host_name.err in the data directory, unless the --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系统变量设置为stderrOtherwise, the default destination is a file and the server sets log_error to the file name.否则,默认目标是一个文件,服务器将log_error设置为文件名。

Default Error Log Destination on Unix and Unix-Like SystemsUnix和类Unix系统上的默认错误日志目标

On Unix and Unix-like systems, mysqld uses the --log-error option to determine whether the default error log destination is the console or a file, and, if a file, the file name:在Unix和类Unix系统上,mysqld使用--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 host_name.err in the data directory.如果在没有命名文件的情况下给出--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。

Note注意

It is common for Yum or APT package installations to configure an error log file location under /var/log with an option like log-error=/var/log/mysqld.log in a server configuration file. Yum或APT软件包安装通常会在服务器配置文件中使用类似log-error=/var/log/mysqld.log的选项在/var/log下配置错误日志文件位置。Removing the path name from the option causes the host_name.err file in the data directory to be used.从选项中删除路径名会导致使用数据目录中的host_name.err文件。

If the default error log destination is the console, the server sets the log_error system variable to stderr. 如果默认的错误日志目标是控制台,则服务器会将log_error系统变量设置为stderrOtherwise, the default destination is a file and the server sets log_error to the file name.否则,默认目标是一个文件,服务器将log_error设置为文件名。

How the Default Error Log Destination Affects Log Sinks默认错误日志目标如何影响日志接收器

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_errorstderr,则默认的错误日志目标是控制台,并且以默认目标为输出目标的日志接收器也会写入控制台:

  • 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 .NN.json suffix: file_name.00.json, file_name.01.json, and so forth.log_error_services值中命名的此接收器的连续实例写入名为file_name的文件加上编号为NN.json的后缀:file_name.00.jsonfile_name.01.json等等。

  • log_sink_syseventlog: This sink writes to the system log, regardless of the log_error value.:无论log_error值为多少,此接收器都会写入系统日志。