When SCF is used for function computation, a large number of function execution logs will be generated. You can view and search for logs generated in the last 15 days in the SCF Console.
If you need to store, deliver, or consume logs in a persistent manner and monitor and set alarms on log content, you can deliver logs to the Tencent Cloud Log Service (CLS) platform.
Before using the SCF real-time log service, you need to activate CLS first.
Creating logsets and log topics
Log in to the CLS Console and create a logset and log topic. This document uses the creation of the
SCF-test log set and log topic in Guangzhou as an example as shown below:
For the logset region, please select the region where the SCF service is located. Cross-region log push is not supported currently.
- Log in to the SCF Console and select Functions on the left sidebar.
- Select the SCF region and namespace at the top of the page and click the function name in the list for which to collect logs in real time.
- On the "Function Configuration" page, click Edit in the top-right corner.
- In "Log Delivery", select the logset and log topic already created for this function. This document uses
SCF-test as an example.
- Click Save to connect to the CLS platform.
If you want to use the log search feature, you need to enable the index manually as instructed below:
- Log in to the CLS Console and select Log Sets on the left sidebar.
- Click the ID of a created logset to enter the "Basic Info" page.
- Select Manage to the right of the log topic row to enter the "Basic Info" page of the log topic.
- On the "Basic Info" page of the log topic, click Index Configuration.
- Click Edit in the top-right corner to enable the index and save the change.
For more information on other features such as real-time log search, delivery, and consumption, please see the CLS documentation. These features can be used in the CLS Console directly.
Example of real-time search
Before using the real-time search feature, please make sure that your SCF log service has been connected to the CLS platform and the index has been enabled for the log topic to be searched.
- Log in to the CLS Console and select Log Search on the left sidebar.
- On the "Search and Analysis" page, select the desired log topic and time and enter the search syntax in the input box. This document uses
START as an example.
The search syntax supports keyword search, fuzzy search, range search, and other search methods. For more information, please see Syntax Rules.
- Click Query and Analyze to view real-time log information.