HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How do I output MySQL logs to syslog?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sysloglogsoutputmysqlhow

Problem

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

Solution

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.

Code Snippets

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

Context

StackExchange Database Administrators Q#3552, answer score: 12

Revisions (0)

No revisions yet.