Discussion:
MySQL general logs to syslog
(too old to reply)
rana chand
2020-10-19 07:21:42 UTC
Permalink
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
2020-10-19 09:08:19 UTC
Permalink
Post by rana chand
Hi All,
Currently all MySQL error logs and general logs are stored in /var/log/mysql/error.log and /var/log/mysql/mysql.log
[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.
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
2020-10-19 09:53:52 UTC
Permalink
Post by rana chand
Currently all MySQL error logs and general logs are stored in
/var/log/mysql/error.log and /var/log/mysql/mysql.log
Post by rana chand
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
2020-10-19 18:49:59 UTC
Permalink
Post by rana chand
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
[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.
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"
Loading...