tencent cloud

Serverless Cloud Function

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Related Concepts
How It Works
Strengths
Scenarios
Related Products
Purchase Guide
Billing Overview
Billing Mode
Billable Items and Billing Modes
Function Computing Power Support
Free Tier
SCF Pricing
Billing Example
Payment Overdue
Getting Started
Creating Event Function in Console
User Guide
Quota Management
Managing Functions
Web Function Management
Log Management
Concurrence Management
Trigger Management
Function URL
A Custom Domain Name
Version Management
Alias Management
Permission Management
Running Instance Management
Plugin Management
Managing Monitors and Alarms
Network Configuration
Layer Management
Execution Configuration
Extended Storage Management
DNS Caching Configuration
Resource Managed Mode Management
Near-Offline Resource Hosting Model
Workflow
Triggers
Trigger Overview
Trigger Event Message Structure Summary
API Gateway Trigger
COS Trigger
CLS Trigger
Timer Trigger
CKafka Trigger
Apache Kafka Trigger
MQTT Trigger
Trigger Configuration Description
MPS Trigger
CLB Trigger Description
TencentCloud API Trigger
Development Guide
Basic Concepts
Testing a Function
Environment Variables
Dependency Installation
Using Container Image
Error Types and Retry Policies
Dead Letter Queue
Connecting SCF to Database
Automated Deployment
Cloud Function Status Code
Common Errors and Solutions
Developer Tools
Serverless Web IDE
Calling SDK Across Functions
Third-Party Tools
Code Development
Python
Node.js
Golang
PHP
Java
Custom Runtime
Deploying Image as Function
Web Framework Development
Deploying Framework on Command Line
Quickly Deploying Egg Framework
Quickly Deploying Express Framework
Quickly Deploying Flask Framework
Quickly Deploying Koa Framework
Quickly Deploying Laravel Framework
Quickly Deploying Nest.js Framework
Quickly Deploying Next.js Framework
Quickly Deploying Nuxt.js Framework
Quickly Deploying Django Framework
Use Cases
Overview
Solutions with Tencent Cloud Services
Business Development
TRTC Practices
COS Practices
CKafka Practice
CLS
CLB Practice
MPS
CDN
CDWPG
VOD
SMS
ES
Scheduled Task
Video Processing
Success Stories
Tencent Online Education
Online Video Industry
Tencent Online Education
Best Practice of Tencent IEG Going Global
API Documentation
History
Introduction
API Category
Making API Requests
Other APIs
Namespace APIs
Layer Management APIs
Async Event Management APIs
Trigger APIs
Function APIs
Function and Layer Status Description
Data Types
Error Codes
SDK Documentation
FAQs
General
Web Function
Billing FAQs
Network FAQs
Log FAQs
SCF utility class
Event Handling FAQs
API Gateway Trigger FAQs
Related Agreement
Service Level Agreement
Contact Us
Glossary

Log Delivery Configuration

PDF
Focus Mode
Font Size
Last updated: 2024-12-02 20:07:18
Note:
If your function was created before January 29, 2021 and has not been migrated, but you want to use more log analysis features, deliver function invocation logs to CLS as instructed in Log Delivery Configuration (Legacy).
SCF was fully connected to Tencent Cloud CLS starting from January 29, 2021. After then, the invocation logs of newly created functions will be delivered to CLS, and logs can be output in real time. The existing functions are gradually migrated by regions. For more information, see SCF Log Service Change Notification.
This document describes the two log delivery methods of default delivery and custom delivery provided by SCF and how to configure them.

Permission Description

To view the logs normally, ensure that the sub-account at least has the read-only permission of CLS QcloudCLSReadOnlyAccess. For how the root account grant permissions for the sub-account, see Authorization Management.

Restrictions

Delivering function invocation logs to CLS has the following limits:
The maximum amount of logs printed within 5 seconds for each request is 1 MB.
The maximum number of logs printed within 5 seconds for each request is 5000.
The maximum length of each log is 8 KB, and excessive parts will be discarded.

Directions

Default delivery

When creating a function, if you don't specify the destination topic for log delivery, the default log delivery capability will be used. For default log delivery, SCF will activate the CLS service for you and deliver the function invocation logs to the log topic under the SCF-specific logset. The SCF-specific logset and log topic are prefixed with SCF_logset and SCF_logtopic respectively, and will be created automatically if they do not exist. Function invocation logs will be retained for 7 days by default, and you can view and manage them on the CLS console.
Note:
CLS is billed separately, and the SCF-specific log topic will consume the free tier of CLS. For more information, see Billing Overview.
To ensure the proper display of logs in the SCF console, SCF-specific log topics do not support modifying the log index configuration. To customize the index configuration, configure the function log topic as instructed in Custom delivery below.

Configuring CLS

1. Log in to the SCF console and select Functions on the left sidebar.
2. Select the region and namespace where to create a function at the top of the page and click Create to enter the function creation process.
3. In Log configuration, select Default as shown below:


4. Click Complete. You can view the log configuration in Function management > Function configuration as shown below:



Viewing and managing logs

You can click the logset ID in Log Configuration in Function Configuration to enter the CLS console to view and manage logs. The SCF-specific logset is marked with the word SCF in the CLS console. If you need to persistently store, deliver, or consume logs or monitor and set alarms on log content, you can complete the configuration in the CLS console.

Custom delivery

When creating a function, if you need to specify the destination log topic to deliver function invocation logs, you can use the custom log delivery capability. Before using this capability, you should make sure that the CLS service has been activated.

Creating logset and log topic

Log in to the CLS console and create a log topic. This document uses the creation of the SCF-test log topic in Guangzhou as an example as shown below:


Note:
For the logset region, select the region where the SCF service is located. Cross-region log push is not supported currently.

Configuring CLS

1. Log in to the SCF console and select Functions on the left sidebar.
2. Select the region where to create a function at the top of the page and click Create to enter the function creation process.
3. In Log configuration, select Custom and select the log topic already created for this function. This document uses SCF-test as an example as shown below:


4. Click Confirm.

Configuring indexes

Log search depends on the index configuration of the log topic. SCF will automatically complete the index configuration when you create a function. If the index is abnormal and logs cannot be viewed properly, configure the index in the following steps:
1. Log in to the SCF console and select Functions on the left sidebar.
2. On the Function Service list page, select the name of the function whose index is abnormal to enter the Function Management page.
3. On the Log Query tab, select Index Configuration in Advanced Retrieval as shown below:


4. On the Index configuration page, enable Index status and Key-value index as shown below:

This configuration method is only valid for scenarios where there are function invocation logs in the log topic; otherwise, manually configure the key-value index by referring to the table below.
Field Name
Field Type
Description
SCF_FunctionName
text
Function name
SCF_Namespace
text
Function namespace
SCF_StartTime
long
Invocation start time
SCF_LogTime
long
Log generation time
SCF_RequestId
text
Request ID
SCF_Duration
long
Function execution duration
SCF_Alias
text
Alias
SCF_Qualifier
text
Version
SCF_MemUsage
double
Function runtime memory
SCF_Level
text
Log4J log level. Default value: INFO
SCF_Message
text
Log content
SCF_Type
text
Log type. Platform: Platform log; Custom: User log
SCF_StatusCode
long
Status code of function execution
SCF_RetryNum
long
Number of retries
To ensure the display effect of the logs in the SCF console, toggle on Enable Statistics for the field in the key-value index configuration.
5. After configuring the index, click OK.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback