This topic describes how to view the error logs of an ApsaraDB RDS for SQL Server instance in the ApsaraDB RDS console or by using SQL statements. You can use the error logs to identify issues. You can also clean up the error logs of an RDS instance to release the disk space in the ApsaraDB RDS console or by calling an API operation. In addition, if a primary/secondary switchover occurs, you can monitor the switchover status by viewing the primary/secondary switchover logs of an RDS instance in the ApsaraDB RDS console.
View error logs
Method 1: View error logs in the ApsaraDB RDS console
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 ID of the instance.
In the left-side navigation pane, click Logs.
On the Error Logs tab, select a time range to search for error logs.
Tab | Description |
Error Logs | Provides logs on events that occurred over the last month. The events include custom events and specific system events. |
Method 2: View error logs by using SQL statements
If your RDS instance runs SQL Server 2016 or earlier, call the sp_rds_read_error_logs
stored procedure to obtain error logs.
EXEC sp_rds_read_error_logs;
EXEC sp_rds_read_error_logs <n>, 1 ,'error';
If your RDS instance runs SQL Server 2017 or later, call the sp_readerrorlog
stored procedure to obtain error logs. For more information, see Microsoft documentation.
Clean up error logs
You can clean up the error logs of an RDS instance to release the disk space in the ApsaraDB RDS console or by calling an API operation. For error logs that have been uploaded to an Object Storage Service (OSS) bucket, you can still view the error logs in the ApsaraDB RDS console, which are not affected by the cleanup operation. For more information, see ModifyDBInstanceConfig.
Note
RDS instances that run SQL Server 2008 R2 do not support the cleanup operation.
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 ID of the instance.
In the left-side navigation pane, click Logs.
On the Error Logs tab, click Clean Disk Space Occupied by Error Logs.
Click OK.
You can view disk usage on the page. For more information, see View storage usage.
View primary/secondary switchover logs
Note
You can view primary/secondary switchover logs only when the primary RDS instance runs SQL Server 2008 R2 with local disks.
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 ID of the instance.
In the left-side navigation pane, click Service Availability.
In the Primary/Secondary Switching Logs section of the page that appears, select a time range and view the primary/secondary switchover logs that are generated over the selected time range.
