LoggingFormat

class aws_cdk.aws_lambda.LoggingFormat(value)

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 customer’s 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=lambda_.SystemLogLevel.INFO,
    application_log_level=lambda_.ApplicationLogLevel.INFO,
    log_group=log_group
)

Attributes

JSON

Lambda structured logging in Json format.

TEXT

Lambda Logs text format.