Enable logs (general, error, slow query) for Amazon RDS databases (MySQL, MariaDB)
March 19, 2021
Log locations are:
- Error:
/rdsdbdata/log/error/mysql-error.log - General:
/rdsdbdata/log/general/mysql-general.log - Slow Query:
/rdsdbdata/log/slowquery/mysql-slowquery.log
MariaDB logs are also named mysql-slowquery.log and mysql-general.log. These file locations (or names) can not be changed.
MySQL Parameters
slow_query_log=1(default value is 0 or no logging)slow_query_log_file=/rdsdbdata/log/slowquery/mysql-slowquery.log(default location)long_query_time=5(to log queries that run longer than five seconds)general_log=1(default value is 0 or no logging)general_log_file=/rdsdbdata/log/general/mysql-general.log(default location)log_output=FILE
To work with the logs from the Amazon RDS console, Amazon RDS API, Amazon RDS CLI, or AWS SDKs, set the log_output parameter to FILE.
MariaDB Parameters
slow_query_log=1slow_query_log_file=/rdsdbdata/log/slowquery/mysql-slowquery.loglong_query_time=5general_log=1general_log_file=/rdsdbdata/log/general/mysql-general.loglog_output=FILE
Notes
- The changes require a reboot to take effect. You have to manually reboot it,
pending_rebootwill NOT result in an automatic reboot during the next maintenance window. log_outputwas set to file because setting it to table can effect the database performance for high throughput workload. Setting it toFILEmeans you can view the logs from the RDS console, but you can not query them.
To work with the logs from the Amazon RDS console, Amazon RDS API, Amazon RDS CLI, or AWS SDKs, set the log_output parameter to FILE.
- If the option is set to
TABLEthen the amount of data written to the table can increase, which can also effect performance due to resources used to write to this table. - For the dev db where performance is not that big of a concern, i have set it to
TABLE, and for the prod db i have set it toFILE.