LoggingFormat

class aws_cdk.aws_lambda.LoggingFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

This field takes in 2 values either Text or JSON.

By setting this value to Text, will result in the current structure of logs format, whereas, by setting this value to JSON, Lambda will print the logs as Structured JSON Logs, with the corresponding timestamp and log level of each event. Selecting ‘JSON’ format will only allow customers to have different log level Application log level and the System log level.

ExampleMetadata:

infused

Example:

from aws_cdk.aws_logs import ILogGroup

# log_group: ILogGroup


lambda_.Function(self, "Lambda",
    code=lambda_.InlineCode("foo"),
    handler="index.handler",
    runtime=lambda_.Runtime.NODEJS_18_X,
    logging_format=lambda_.LoggingFormat.JSON,
    system_log_level_v2=lambda_.SystemLogLevel.INFO,
    application_log_level_v2=lambda_.ApplicationLogLevel.INFO,
    log_group=log_group
)

Attributes

JSON

Lambda structured logging in Json format.

TEXT

Lambda Logs text format.