All Products
Search
Document Center

ApsaraDB RDS:Manage logs

Last Updated:Mar 28, 2026

ApsaraDB RDS for SQL Server records instance events as error logs. Use these logs to diagnose issues, free up disk space by cleaning up accumulated log files, and monitor primary/secondary switchover events.

Prerequisites

Before you begin, ensure that you have:

View error logs

The console shows error logs from the last month only. For logs older than one month, use SQL statements.

View error logs in the console

  1. Go to the Instances page. In the top navigation bar, select the region where your instance resides, then click the instance ID.

  2. In the left-side navigation pane, click Logs.

  3. On the Error Logs tab, select a time range to filter results.

The Error Logs tab shows events from the past month, including custom events and specific system events.

To view error logs older than one month, use SQL statements as described in the next section.

View error logs by using SQL statements

SQL Server 2016 or earlier

Call the sp_rds_read_error_logs stored procedure.

-- Return all error logs
EXEC sp_rds_read_error_logs;

-- Return error logs from log file N that contain a specific keyword
EXEC sp_rds_read_error_logs <n>, 1, 'error';

SQL Server 2017 or later

Call the sp_readerrorlog stored procedure.

EXEC sp_readerrorlog;

For the full parameter reference, see the Microsoft documentation.

Clean up error logs

Cleaning up error logs removes log files from the instance to free disk space. Error logs already uploaded to an Object Storage Service (OSS) bucket remain accessible in the console after cleanup.

SQL Server 2008 R2 instances do not support this operation.
  1. Go to the Instances page. In the top navigation bar, select the region where your instance resides, then click the instance ID.

  2. In the left-side navigation pane, click Logs.

  3. On the Error Logs tab, click Clean Disk Space Occupied by Error Logs.

  4. Click OK.

After cleanup, check disk usage on the Monitoring and Alerts page. For details, see View storage usage.

To automate cleanup using the API, call ModifyDBInstanceConfig.

View primary/secondary switchover logs

This feature is only available for primary RDS instances running SQL Server 2008 R2 with local disks.
  1. Go to the Instances page. In the top navigation bar, select the region where your instance resides, then click the instance ID.

  2. In the left-side navigation pane, click Service Availability.

  3. In the Primary/Secondary Switching Logs section, select a time range to view the switchover logs generated during that period.

image.png

What's next