Mysql – Configuring MariaDB to log to thesql.log using rsyslog

debianmariadbMySQLrsyslog

I'm a little stumped – there is something obvious I'm missing here. Recently I made the switch from mySQL to mariaDB. Everything is working so far – except for the logging, as I realized today.

All the logs of mariaDB are going into the /var/log/daemon.log-logfile instead of /var/log/mysql.log – and I cannot, for the life of me, figure out why.

So, according to the my.cnf of mariadb

# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# we do want to know about network errors and such
log_warnings            = 2

the logging is configured in /etc/mysql/conf.d/mysqld_safe_syslog.cnf. This file contains these line:

[mysqld_safe]
syslog
syslog-facility = mysql

So, okay – that should be fine, right?
But ps -ef|grep logger shows:

logger -t mysqld -p daemon.error

So…what? Why? I really do not understand why it is taking the "daemon" facility?
Okay, so digging a little deeper – I found the following. When trying to test the logging by invoking the logger myself, I get the following:

$> logger -p mysql.error test
logger: unknown facility name: mysql.

Okay, I thought – although that makes no sense to me, just use local1 then for now. But doing so, in changing the value in the mysqld_safe_syslog.cnf to

syslog-facility = local1

changes exactly nothing:

$> ps -ef|grep logger
logger -t mysqld -p daemon.error

I looked around, but could not find any viable information on this topic. Can you help me out? How do I get mariadb to log somewhere else?

Best Answer

Well, that was easy - my init-script was borked:

# priority can be overriden and "-s" adds output to stderr
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"

Changed it and everything is fine. Didn't come to think of actually checking the init script... well... next time ;)

Related Topic