This topic describes how to manage logs through the RDS console or by using SQL statements. You can query error logs and slow query logs. The log query results help you to locate faults.

You can query error logs, slow query logs, and primary/secondary instance switching logs of an instance through the console or by running SQL commands. These logs help you troubleshoot database issues. This topic describes how to manage logs through the console.

Note
  • PostgreSQL 10 Basic Edition does not support logs about switching between the primary database and secondary database.
  • PostgreSQL 11 Cluster Edition (Standard SSD) and PostgreSQL 10 Cluster Edition (Standard SSD) do not support manage logs through the console. However, you can use SQL commands to query and manage logs.

Prerequisites

The instance edition must be one of the following editions:
  • PostgreSQL 10 Cluster Edition (Local SSD)
  • PostgreSQL 10 Basic Edition
  • PostgreSQL 9.4

Procedure

  1. Log on to the ApsaraDB for RDS console.
  2. In the upper-left corner of the page, select the region where the instance is located.

  3. Find the instance and click the instance ID.
  4. In the left-side navigation pane, click Logs.
  5. On the Logs page, select the Error Log, Slow Query Log or Primary/Secondary Instance Switching Log tab, select a time range, and click Update.
    Log type Description
    Error log Records the logs of database errors within one month.
    Slow query log Records the logs of SQL statements whose execution period exceeds one second in the database within a month and removes the duplicates in the logs.
    Primary/secondary instance switching log Records the logs of switching between the primary and secondary databases within one month.
    Note Instances in China (Zhangjiakou-Beijing Winter Olympics) only retain the error logs and slow query logs within nine days.

API reference

Operation Description
DescribeSlowLogs You can call this operation to query the list of slow query logs.
DescribeSlowLogRecords You can call this operation to query the details of slow query logs.
DescribeErrorLogs You can call this operation to query error logs.
DescribeBinlogFiles You can call this operation to query binlogs.
DescribeSQLLogRecords You can call this operation to query audit logs.
DescribeSQLLogFiles You can call this operation to query the list of audit log files.