aws-cdk-lib.aws_apigateway.AccessLogFormat

class AccessLogFormat

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.AccessLogFormat
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#AccessLogFormat
Javasoftware.amazon.awscdk.services.apigateway.AccessLogFormat
Pythonaws_cdk.aws_apigateway.AccessLogFormat
TypeScript (source)aws-cdk-lib » aws_apigateway » AccessLogFormat

factory methods for access log format.

Example

 apigateway.AccessLogFormat.custom(JSON.stringify({
     requestId: apigateway.AccessLogField.contextRequestId(),
     sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(),
     method: apigateway.AccessLogField.contextHttpMethod(),
     userContext: {
       sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'),
       email: apigateway.AccessLogField.contextAuthorizerClaims('email')
     }
  }))

Methods

NameDescription
toString()Output a format string to be used with CloudFormation.
static clf()Generate Common Log Format.
static custom(format)Custom log format.
static jsonWithStandardFields(fields?)Access log will be produced in the JSON format with a set of fields most useful in the access log.

toString()

public toString(): string

Returns

  • string

Output a format string to be used with CloudFormation.


static clf()

public static clf(): AccessLogFormat

Returns

  • AccessLogFormat

Generate Common Log Format.


static custom(format)

public static custom(format: string): AccessLogFormat

Parameters

  • format string

Returns

  • AccessLogFormat

Custom log format.

You can create any log format string. You can easily get the $ context variable by using the methods of AccessLogField. Example

 apigateway.AccessLogFormat.custom(JSON.stringify({
     requestId: apigateway.AccessLogField.contextRequestId(),
     sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(),
     method: apigateway.AccessLogField.contextHttpMethod(),
     userContext: {
       sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'),
       email: apigateway.AccessLogField.contextAuthorizerClaims('email')
     }
  }))

static jsonWithStandardFields(fields?)

public static jsonWithStandardFields(fields?: JsonWithStandardFieldProps): AccessLogFormat

Parameters

  • fields JsonWithStandardFieldProps

Returns

  • AccessLogFormat

Access log will be produced in the JSON format with a set of fields most useful in the access log.

All fields are turned on by default with the option to turn off specific fields.