Bug #51820 Error log is automatically named after the PID file's name
Submitted: 8 Mar 2010 9:12 Modified: 8 Mar 2010 10:49
Reporter: Guilhem Bichot Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.0, 5.1, 5.5-m3, 6.0-codebase OS:Any
Assigned to: CPU Architecture:Any

[8 Mar 2010 9:12] Guilhem Bichot
Description:
This seems to be yet another form of BUG#33693, this time applied to the error log.

http://dev.mysql.com/doc/refman/5.5/en/error-log.html
says, about --log-error:
"If no file_name value is given, mysqld uses the name host_name.err by default. The server creates the file in the data directory unless an absolute path name is given to specify a different directory."

This was true but changed; looking at code it seems to have changed starting from 5.0. A more correct description of the new behaviour would be something like:
"If no file_name value is given, mysqld uses the path and name of the PID file, with a .err extension".
I verified that if --pid-file=/some/fancy/path/name --log-error is used,
then the Error log will be put into /some/fancy/path/name.err. Not in the datadir, and not named `hostname`.err, contradicting the documentation.

This is a difference from other logs (binary log, general log, slow query log), which are still put into datadir by default if no path is given, independently of the PID file.

The relevant code is in mysqld.cc:
  if (opt_error_log && !opt_help)
  {
    if (!log_error_file_ptr[0])
      fn_format(log_error_file, pidfile_name, mysql_data_home, ".err",
                MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
    ...
and note that it was written this way in relation to BUG#20166.

How to repeat:
start mysqld with --log-error --pid-file=/some/fancy/path/name
you will see that the Error Log is not put into the datadir.
[8 Mar 2010 10:49] Valeriy Kravchuk
Thank you for the problem report. Verified just as described with 5.1.45-bzr on Mac OS X.
[9 Mar 2010 9:49] Magne Mæhre
See also:  Bug #45359 binary and relay log file names depend on PID file name
[9 Mar 2010 9:56] Guilhem Bichot
Hello Triage; as this is the same bug as BUG#33693 except that it applies to a different type of log, I suggest the same triage/priority as for BUG#33693 (D3 W4 I3 P3).