Print function logs

更新时间:
复制 MD 格式

Function Compute captures all output written to STDOUT and STDERR and uploads it to the Logstore you configure. Use log printing to verify logic and debug functions during development.

How it works

  1. Your function writes log output to STDOUT or STDERR.

  2. The Function Compute runtime collects this output and uploads it to your configured Logstore.

  3. Each log entry is tagged with the log topic functionName, where functionName is the name of your function.

To find logs for a specific function, search by log topic:

__topic__: "FCLogs:functionName"

Log format

Include the request ID in every log entry to simplify troubleshooting. The recommended format is:

$utcdatetime(yyyy-MM-ddTHH:mm:ss.fff) $requestId [$Level] $message

Example log entry:

2023-10-23 15:43:19 1-65362416-68afb557d64a2e283eccebce [info] hello world
FieldDescriptionExample
$utcdatetimeUTC timestamp in millisecond precision2023-10-23 15:43:19
$requestIdUnique ID for the function invocation1-65362416-68afb557d64a2e283eccebce
[$Level]Log severity level[info]
$messageLog message contenthello world

Runtimes that use context.getLogger() apply this format automatically.

Log printing by runtime

For runtime-specific instructions on printing and viewing logs, see: