Function logs
A function writes logs to Yandex Cloud Logging, to the default log group for the folder where the function is located.
There are two types of logs:
- Automatic: Logs of requests to functions.
- Custom: Logs that custom code writes to the standard output (
stdout) and standard error output (stderr). The minimum logging level of custom logs isUNSPECIFIED.
Learn more about working with logs in the Yandex Cloud Logging documentation.
Structured logs
Apart from text, you can write structured logs in the following JSON format to the standard output (stdout) and standard error output (stderr):
message/msg: Entry text.level: Logging level. The available levels areTRACE,DEBUG,INFO,WARN,ERROR, andFATAL.stream_name: Log stream name. It must be from 1 to 63 characters long.
All other JSON fields are automatically written to json-payload.
A log must be single-line. Any entry that contains the message/msg field and is up to 64 KB is considered a structured log. If a log entry is too large, it is split into multiple entries and treated as text.
You can disable structured logs by setting STRUCTURED_LOGGING = false. In this case, any JSON log will be considered plain text.
Structured logging can be used for concurrent function instance calls to log the IDs of all calls processed by the function, not just the most recent one. To do this, specify a unique call ID in the request_id field. You can get it from the function call context; the way to do this is runtime-specific.