MySQL – How to Output MySQL Logs to Syslog

logsMySQL

I want to use syslog for logging MySQL(5.1.41) on Ubuntu(10.04 LTS).
I found information that output error log to syslog.

[mysqld_safe]
syslog

But I want to use syslog for logging general logs and slow query logs.
Please advise me how to write config file?

I could not find how to do that in the reference manual.

http://dev.mysql.com/doc/refman/5.1/en/log-destinations.html

Best Answer

This is MUCH more simply done this way:

cd to mysql folders:

mkfifo mysql-general.log

in my.cnf tell it:

[mysqld]
general-log-file = /path/to/mysql/dir/mysql-general.log

Then, configure your syslog/syslog-ng to read the FIFO pipe and do with it as it will..

In my case, I pipe it across net to a centralized server with only the error logs and slow query logs however.

In situations where you want to also keep local copy, just set it to output to table and file as described above.