PolarDB log subscription delivers all PolarDB for MySQL cluster logs to a central project in Simple Log Service (SLS) for centralized management and analysis. This topic explains how to enable, view, and disable log collection.
Prerequisites
Before you begin, make sure that:
Your cluster is a PolarDB for MySQL cluster
To collect audit logs, SQL Explorer is enabled for the cluster. SQL Explorer is billed based on audit log storage size.
SQL Explorer is not required if you only collect slow query logs or performance logs.
Supported log types
Audit logs
Slow query logs
Error logs
Performance logs
Enable log collection
Log on to the Simple Log Service console.
In the Log Application section, select the Audit & Security tab and click Log Audit Service.

Configure authorization for log collection and synchronization.
Same-account collection: Follow the on-screen instructions. For details, see Initially configure Log Audit Service.
Multi-account collection: See Custom authentication mode.
Choose Access to Cloud Products > Global Configurations, then complete the following settings:
In the Region of the Central Project drop-down list, select the region where you want to store collected logs.
The system automatically creates a central project in the selected region. All logs configured in the following steps are delivered to this project. The project name follows the format slsaudit-center-<Alibaba Cloud account ID>-<region ID>. For more information, see Project.Select the log types to collect: Audit Logs, Slow Query Logs, Error Logs, or Performance Logs.

Click Collection Policy next to each log type you want to collect. In the Collection Policy Configuration dialog box, add the regions where your clusters reside. If no region is specified, the system creates a Logstore for each region. For more information, see Logstore and Configure log collection policies.
The following parameters are available in collection policies for PolarDB for MySQL clusters:
Parameter Description Example account.idAlibaba Cloud account ID that the cluster belongs to — regionRegion where the cluster is deployed cn-hangzhoucluster.idCluster ID — cluster.nameCluster name — cluster.db_typeDatabase type (only MySQL is supported) MySQLcluster.db_versionDatabase version 8.0,5.7, or5.6tag.*Tag name. Replace *with a custom tag name. See Add tags.— Click OK after completing the configuration.
Click Save in the upper-right corner.
NoteChanges take effect in about 2 minutes. If an error occurs, follow the on-screen instructions to update the configuration.

In the confirmation dialog box, click Go to Access Status to verify that log collection is active. Alternatively, choose Access to Cloud Products > Status Dashboard in the navigation pane to check the collection status for each log type.
View collected logs
Log on to the Simple Log Service console.
On the Global Configurations tab, click the central project. The project name follows the format
slsaudit-center-<Alibaba Cloud account ID>-<region ID>.
Select the Audit Query tab, then click PolarDB to expand the Logstore and view log details.

Disable log collection
Disable the PolarDB log collection feature. See What to do next.
NoteChanges take effect in about 2 minutes.
Open Cloud Shell.
Run the following command to delete the Logstore:
ImportantThis operation deletes all data from a project. Proceed with caution.
aliyunlog log delete_project --project_name=<project name> --region-endpoint=<region ID>.log.aliyuncs.com
Log fields
For a full list of log fields, see The fields of PolarDB for MySQL logs.