You can view error logs and slow query logs for an ApsaraDB RDS for PostgreSQL instance through the ApsaraDB RDS console or by using SQL statements. These logs help you identify database issues and optimize query performance.
This topic covers error logs and slow query logs only. For information about archived logs, see Back up an ApsaraDB RDS for PostgreSQL instance and Download backup files.
Log types
The following table describes the log types available on the Logs page.
| Log type | Description | Retention period |
|---|---|---|
| Error Logs | Records database running errors. | Most recent 30 days |
| Slow Log Details | Records SQL statements that took longer than 1 second to execute. Duplicate SQL statements are removed. | Most recent 7 days |
If the RDS instance resides in the China (Zhangjiakou) region, only the error logs and slow query logs generated over the most recent 9 days are retained.
ApsaraDB RDS collects CSV log file content from databases and saves it to a log server for you to view. To adjust the maximum number of CSV log files retained in the database, modify the instance parameter rds_max_log_files. A larger number of retained CSV log files increases the time required to complete a query and the storage space consumed.
View logs in the console
Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.
In the left-side navigation pane, click Logs.
On the Logs page, select Error Logs or Slow Log Details, and then select a time range. The system displays the log details for the specified time period.
Related API operations
You can also manage logs programmatically through the following API operations.
API operation | Description |
|---|---|
Queries the slow query logs of an instance. | |
Queries the details about the slow query logs of an instance. | |
Queries the error logs of an instance. | |
Queries the WAL (write-ahead log) files of an instance. | |
Queries the SQL audit logs of an instance. | |
Queries the SQL audit log files of an instance. |