Enable Log Service
- Log on to the Container Service console.
- Click Clusters in the left-side navigation pane.
- Click Manage at the right of the cluster.
- Click Enable Log Service in the upper-right corner.
- In the dialog box, click OK.
Before enabling Log Service in Container Service, activate the RAM service and Log Service first. Click Activate It to activate the RAM service and Log Service if they are not activated yet. The created Log Service project is displayed after Log Service is successfully enabled.
Check installation result of acslogging service
Container Service installs the Agent required by Log Service on your machine if this is the first time Log Service is enabled.You can use Log Service after the application is installed successfully. You can find this application on the Application List page. You can use Log Service after the application is installed successfully.
- Log on to the Container Service console.
- Click Applications in the left-side navigation pane.
- Select the cluster from the Cluster list and clear the Hide System Applications check box.
The acslogging application is successfully installed.

Use Log Service in orchestration files
Most Docker applications write the logs directly to stdout, now you can do this as well (for the scenarios of writing logs to files, see Use file logs in the following section). After enabling Log Service, stdout logs are automatically collected and sent to Alibaba Cloud Log Service.
In the following example a WordPress application is created. It contains two services: WordPress service and MySQL service. Logs are collected to Alibaba Cloud Log Service. which contains two services: WordPress service and MySQL service. Logs are collected to Alibaba Cloud Log Service.
MySQL and WordPress
mysql:
image: mysql
ports:
- 80
labels:
aliyun.scale: "1"
environment:
- MYSQL_ROOT_PASSWORD=password
web:
image: registry.aliyuncs.com/jiangjizhong/wordpress
ports:
- 80
labels:
aliyun.routing.port_80: wordpress-with-log
aliyun.log_store_dbstdout: stdout # Collect stdout logs to the dbstdout Logstore.
aliyun.log_ttl_dbstdout: 30 # Set the data retention time for the dbstdout Logstore to 30 days.
links:
- mysql
In the preceding orchestration file:
aliyun.log_store_dbstdout: stdout
indicates to write the container standard to the Logstoreacslog-wordpress-dbstdout
. The label format isaliyun.log_store_{name}: {logpath}
。 Wherein:name
is the name of the Alibaba Cloud Log Service Logstore. The actually created Logstore name isacslog-${app}-${name}
.app
is the application name.logpath
is the log path in the container.stdout
is a speciallogpath
, indicating the standard output.
aliyun.log_ttl_<logstore_name>
is used to set the data retention time (in days) for the Logstore. The value range 1–365. If left empty, logs are kept in the Logstore for two days by default.Note The value configured here is the initial configuration value. To modify the data retention time later, modify it in the Log Service console.
You can create an application named wordpress
in the Container Service console by using the preceding orchestration file. After the application is started, you can find the Logstore acslog-wordpress-dbstdout
in the Log Service console, in which stores the logs of application wordpress
.
View logs in Log Service console
acs-wordpress-dbstdout
used in the orchestration file.

Use file logs
To write the logs directly to files (for example, /var/log/app.log) instead of stdout, configure as follows:
aliyun.log_store_name: /var/log/app.log
name
is the Logstore name. /var/log/app.log is the log path in the container.
To output multiple log files to Log Service, configure as follows to put the files under multiple directories:
aliyun.log_store_s1: /data/logs/access/access.log
aliyun.log_store_s2: /data/logs/error/error.log
aliyun.log_store_s3: /data/logs/exception/*.log #Wildcards are supported
Enable timestamp
You can select whether to add timestamp when Docker is collecting logs. Configure timestamp by using the aliyun.log.timestamp
label in Container Service. label in Container Service. The timestamp is added by default.
- Add timestamp
aliyun.log.timestamp: "true"
- Remove timestamp
aliyun.log.timestamp: "false"