Skip to content
v2.274.0

LoggingFormat 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.

Example ​

ts
import { ILogGroup } from 'aws-cdk-lib/aws-logs';

declare const logGroup: ILogGroup;

new lambda.Function(this, 'Lambda', {
  code: new lambda.InlineCode('foo'),
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_LATEST,
  loggingFormat: lambda.LoggingFormat.JSON,
  systemLogLevelV2: lambda.SystemLogLevel.INFO,
  applicationLogLevelV2: lambda.ApplicationLogLevel.INFO,
  logGroup: logGroup,
});

Members ​

MemberDescription
TEXTLambda Logs text format.
JSONLambda structured logging in Json format.

Referenced by ​

  • FunctionOptions.loggingFormatlogging_formatloggingFormatLoggingFormatLoggingFormat