Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MySQL general logs to syslog

87 views
Skip to first unread message

rana chand

unread,
Oct 19, 2020, 3:21:44 AM10/19/20
to
Hi All,

Currently all MySQL error logs and general logs are stored in /var/log/mysql/error.log and /var/log/mysql/mysql.log

I want to redirect these logs to syslog. So, I have addes the following to the configuration file of mysql:

[mysqld]
log-syslog = on

Now only MySQL error logs are only redirected to the syslog.
Is there a way to redirect both the error and general logs to syslog.

Regards,
Rana

J.O. Aho

unread,
Oct 19, 2020, 5:08:23 AM10/19/20
to
I haven't really been trying to move the logging of, but it seems that
people have created a fifo pipe, log to it and then configure the syslog
to read that fifo pipe as a source.

https://dba.stackexchange.com/questions/3552/how-do-i-output-mysql-logs-to-syslog

As far as I can see, mysql supports only error log written to syslog
with the configuration options the daemon supplies.

--

//Aho

Axel Schwenke

unread,
Oct 19, 2020, 5:53:55 AM10/19/20
to
On 19.10.2020 09:21, rana chand wrote:
>
> Currently all MySQL error logs and general logs are stored in
/var/log/mysql/error.log and /var/log/mysql/mysql.log
>
> I want to redirect these logs to syslog.
> Now only MySQL error logs are only redirected to the syslog.
> Is there a way to redirect both the error and general logs to syslog.

Not for the general log. You can have that written to a log file or to a
database table (typically using the CSV storage engine). IMNSHO the only
sensible option here is to write the general log to a file.

The reasons is this: the general log tends to create tremendous amounts of
data. It logs not only each SQL statement, but also connect and disconnect.
That means that you need the most efficient way of storing this data - which
is a file. Syslog is not designed to handle that amount of data. Or that
rate of incoming messages. Even a log file you will want to rotate rather
often (easily done by renaming the file and doing FLUSH LOGS). I now read
that log tables can be rotated with RENAME TABLE. Good. It's still only the
second best solution.

Keep also in mind that the general log is nothing that you should enable
light-heartedly. Not on a production system anyway. It makes most sense as a
debugging aid.

Lew Pitcher

unread,
Oct 19, 2020, 2:50:03 PM10/19/20
to
Apparently, not from within mysqld. According to
https://dev.mysql.com/doc/refman/5.7/en/query-log.html
the "General Query Log" can only be directed to a file or a mysql table
(or both a file and a table), or not output at all.

From the syslog side, syslogd /can/ read from a UNIX-domain socket (if
configured to do so), so you /might/ be able to direct the general query-
log to a "file", with that file being a UNIX-domain socket input known to
syslogd.

I don't know if this will work; I've never tried it.

--
Lew Pitcher
"In Skills, We Trust"
0 new messages