I was to able to enable Error log, General Query log, Slow Query Log and Binary Log and was able to forward the logs to Syslog. I have few questions about logging.
1) The error log is automatically forwarded to Event log in Windows. How do I forward the other logs to event log as well?
2) Is it possible to convert the multiline mysql logs to single line.
3) Is it possible to add some header to the log files or some tag at the beginning of each log line so that it is easy to identify which log file it is.
4) In the slow query logs, some information is commented. When forwarded using rsyslog, will these commented lines be forwarded in all the Unix systems?
# User@Host: debian-sys-maint[debian-sys-maint] @ localhost []
# Query_time: 0.000297 Lock_time: 0.000220 Rows_sent: 0 Rows_examined: 0
SET timestamp=1539924163;
select count(*) into @discard from `information_schema`.`EVENTS`;
5) mysqlbinlog can be used to convert the binary log to human readable format. Is there a way where I can convert the binary file and forward it to syslog without writing any custom script? Is there a way in mysql or rsyslog?
There is no feature to do this in MySQL.
You can't change the format of the slow-query log without modifying the MySQL source code. It's hard-coded:
And further, for the other lines for each query logged.
But you can get related query performance information from the PERFORMANCE_SCHEMA, and you can even get summaries by query type. There are advantages and disadvantages. See for example this blog: https://www.percona.com/blog/2014/02/11/performance_schema-vs-slow-query-log/
Not without changing the source code.
You can't forward the slow query log to syslog.
No.
But you can use the
mysqlbinlogtool to download remote binary logs as a way of backing them up. See https://dev.mysql.com/doc/refman/8.0/en/mysqlbinlog-backup.html