class AccessLogFormat
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGateway.AccessLogFormat |
Java | software.amazon.awscdk.services.apigateway.AccessLogFormat |
Python | aws_cdk.aws_apigateway.AccessLogFormat |
TypeScript (source) | @aws-cdk/aws-apigateway » AccessLogFormat |
factory methods for access log format.
Example
const logGroup = new logs.LogGroup(this, "ApiGatewayAccessLogs");
new apigateway.RestApi(this, 'books', {
deployOptions: {
accessLogDestination: new apigateway.LogGroupLogDestination(logGroup),
accessLogFormat: apigateway.AccessLogFormat.custom(
`${apigateway.AccessLogField.contextRequestId()} ${apigateway.AccessLogField.contextErrorMessage()} ${apigateway.AccessLogField.contextErrorMessageString()}`
)
}
});
Methods
Name | Description |
---|---|
to | Output a format string to be used with CloudFormation. |
static clf() | Generate Common Log Format. |
static custom(format) | Custom log format. |
static json | Access log will be produced in the JSON format with a set of fields most useful in the access log. |
String()
topublic toString(): string
Returns
string
Output a format string to be used with CloudFormation.
static clf()
public static clf(): AccessLogFormat
Returns
Generate Common Log Format.
static custom(format)
public static custom(format: string): AccessLogFormat
Parameters
- format
string
Returns
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')
}
}))
WithStandardFields(fields?)
static jsonpublic static jsonWithStandardFields(fields?: JsonWithStandardFieldProps): AccessLogFormat
Parameters
- fields
Json
With Standard Field Props
Returns
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.