This topic describes how to enable the logging feature in the Function Compute console. After you enable the logging feature, function execution logs are delivered to Log Service.

Prerequisites

A service is created. For more information, see Create a service.

Procedure

Important Before you can enable the logging feature as a RAM user, you must grant the required permissions to the RAM user. For more information, see RAM user authorization.
  1. Log on to the Function Compute console.
  2. In the left-side navigation pane, click Services & Functions.
  3. In the top navigation bar, select the region where the service resides.
  4. On the Services page, find the service that you want to manage and click Configure in the Actions column.
  5. On the Modify Service page, configure the parameters and click Save. The following table describes the parameters.
    ParameterDescription
    Service RoleBefore you enable the logging feature, you must select a role that has the permissions to access Log Service resources. For more information about service-linked roles, see Grant Function Compute permissions to access other Alibaba Cloud services.
    Warning Do not revoke the permissions from the RAM role or delete the RAM role. If you revoke the permissions from the RAM role or delete the RAM role, Function Compute execution logs cannot be sent to Log Service.
    LoggingSpecifies whether to enable the logging feature.
    • Enable: If you select this option, you can view the execution logs of functions, and store and query the logs in Log Service.
    • Disable: If you select this option, logs are not collected and delivered to Log Service.
    Log Service ProjectThe Log Service project that is used to manage resources related to function execution logs, such as Logstores.
    LogstoreThe Logstore that is used to store function execution logs.
    Log Rotation RulesSpecifies whether to enable log segmentation.
    • Enable: If you select this option, Function Compute splits function execution logs based on dates. If a line contains a date, the line is recorded as the first line of a new log. Otherwise, the line is recorded as a part of the last log. For example, if a line contains 2021-10-10, the line is recorded as the first line of a log. The first line and the subsequent lines that do not contain dates are delivered to Log Service as a whole log.
    • Disable: If you select this option, Function Compute does not split logs.
    Request-level MetricsSpecifies whether to enable the Insights feature of Function Compute for the service. If you enable the Insights feature, you can view the invocation metrics.
    • Enable: If you select this option, execution metrics for functions in the service are collected and delivered to the specified Logstore.
    • Disable: If you select this option, the Insights feature of Function Compute is disabled for the service. In this case, you cannot view the execution metrics.
    Instance-level MetricsSpecifies whether to enable the collection of instance-level metrics.
    • Enable: If you select this option, instance-level metrics are collected. Instance-level metrics are performance metrics of instances. The instances are monitored, and their performance metrics are collected and displayed in real time. The metrics facilitate end-to-end monitoring and troubleshooting for the instances. For more information, see Instance-level metrics.
    • Disable: If you select this option, instance-level metrics are not collected.

What to do next

After function execution logs are delivered to Log Service, you can query, analyze, download, ship, and transform the logs in the Log Service console. You can also create alerts rules for the logs. For more information, see Common operations on logs of Alibaba Cloud services.