- MySQL is used as back-end for syslog to store the logging information. 
- MySQL itself should report to the syslog.
Since the version 5.1.20 MySQL is capable to log to the syslog , . This is done by the MySQL angel process mysqld_safe.
You can enable the syslog when you add the syslog parameter to the MySQL configuration file (my.cnf) in the mysqld_safe section:
Currently MySQL is not capable to log to more than one logging facility at the same time. So you have to decide if you want to log either to the error log or to the syslog.
If you specify both, syslog and error-log, at the same time you will receive an error message if you start mysqld like this:
But I assume that most of the MySQL users are using some kind of start/stop wrapper script like the mysql.server as follows:
So you will never see the error message indicating you having a conflict between the syslog and the error log. And you are possibly wondering why it is not logging to the syslog. For this problem I have filed a bug report .
If you cannot wait for the fix, this excerpt of mysqld_safe should help :
364 if [ $want_syslog -eq 1 ]
366 # User explicitly asked for syslog, so warn that it isn't used
367 logging=file # This line you have to add!
368 log_error "Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect."
Logging to an other logging facility than daemon
Mysqld_safe uses the logger command to log the error messages to the syslog. With ps you will find a command which looks like this:
logger -t mysqld -p daemon.error
The logger command uses 2 parameters -t for tag and -p for priority. The tag can be influenced with the syslog-tag parameter .
The priority parameter configures into which facility and on which level the message should be logged.
An exceprt from the logger man page :
Enter the message with the specified priority. The priority may be specified numerically or as a ''facility.level'' pair. For example, ''-p local3.info'' logs the message(s) as informational level in the local3 facility. The default is ''user.notice.''
Unfortunately the logging facility is hard-coded in the the mysqld_safe script as daemon.error and daemon.notice. It would be nice to have this parameter configurable as well thus I have filed a feature request for it .
When you cannot wait, this code snippets from mysqld_safe possibly will help you :
> log_generic $syslog_facility.error "$@" >&2
<> log_generic $syslog_facility.notice "$@"
< cmd="">&1 | logger -t '$syslog_tag_mysqld' -p daemon.error"
> cmd="$cmd 2>&1 | logger -t '$syslog_tag_mysqld' -p '$syslog_facility'.error"
> --syslog-facility=*) syslog_facility="$val" ;;
With the modified mysqld_safe you can change your MySQL configuration file (my.cnf) file as follows:
syslog-facility = local3
to log to the local3 logging facility for example.
To activate this facility you possibly have to adapt your syslog configuration file (in my case: /etc/rsyslog.d/50-default.conf, in other cases: /etc/syslog.conf) as follows:
To make these changes active you have to restart the syslog daemon:
kill -KILL $(cat /var/run/rsyslogd.pid)
In my case kill -HUP was not strong enough because it did NOT display configuration errors in the log file.
After the restart of the syslog daemon you should find the created empty log file and you can test if the logging works with the following command:
logger -p local3.info test
Now MySQL should log everything to your syslog facility local3.
How to make MySQL logging to the error log AND the syslog facility?
Under normal circumstances mysqld_safe can not log to more than one logging facility.
With the following syslog configuration you can make MySQL logging to both facilities, the error log AND the syslog. Add the following lines to your syslog configuration file:
# Set the owner and group back to its original values
Then restart the syslog daemon as described above and you will see logging to both location. The only drawback is, that the messages in the MySQL error log look like the typical syslog messages and not like the typical MySQL error log messages any more. But this should be somehow configurable with the syslog parameters in its configuration file .
If you need more assistance with logging to the syslog please feel free and drop me a line.
 MySQL error log
 mysqld_safe syslog parameter
 Bug #50083: error-log and syslog conflict in mysqld_safe is not reported to the log file.
 mysqld_safe syslog-tag parameter
 Bug #50080: syslog priority cannot be configured
 Writing syslog messages to MySQL
 Logger man page
 Modified mysqld_safe for advance syslog logging