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.

View logs by using the RDS console

Prerequisites

The DB engine version is SQL Server 2008 R2.

Procedure

  1. Log on to the RDS console.
  2. In the upper-left corner, select the region where the target RDS instance is located.
    选择地域
  3. Find the target RDS instance and click the instance ID.
  4. In the left-side navigation pane, click Log Management.
  5. On the Log Management page, select Error Log, Slow Query Log, Slow Query Log Summary, or Primary/Secondary Instance Switch Log, select a time range, and click Search.
    Query item Description
    Error Log Records the SQL statements that are failed to be executed within the last one month.
    Slow Query Log Records the SQL statements that lasted for more than 1 second within the last one month. (You can reconfigure the long_query_time parameter to change this time threshold.)
    Primary/Secondary Instance Switch Log Records logs related to the switchovers between the master and slave instances within the last one month.

View logs by using SQL statements

Prerequisites

The DB engine version is one of the following:

  • SQL Server 2012
  • SQL Server 2016
  • SQL Server 2017

Procedure

If the used DB engine version is SQL Server 2012 or SQL Server 2016, you can read error logs only by using the sp_rds_read_error_logs stored procedure, which works in the same way as the sp_readerrorlog stored procedure.

Example 1:

EXEC sp_rds_read_error_logs

Example 2:

EXEC sp_rds_read_error_logs 0,1 ,'error'

If the used DB engine version is SQL Server 2017, you can read error logs by using the sp_readerrorlog stored procedure.

Example :

EXEC sp_readerrorlog