I have an AWS API Gateway and this is my CDK code:
const api = new aws_apigateway.RestApi(this, 'kartal', {
restApiName: "kartal",
deployOptions: {
stageName: process.env.ENVIRONMENT,
loggingLevel: aws_apigateway.MethodLoggingLevel.INFO,
metricsEnabled: true,
accessLogFormat: aws_apigateway.AccessLogFormat.custom(JSON.stringify({
requestId: aws_apigateway.AccessLogField.contextRequestId(),
ip: aws_apigateway.AccessLogField.contextIdentitySourceIp(),
requestTime: aws_apigateway.AccessLogField.contextRequestTime(),
resourcePath: aws_apigateway.AccessLogField.contextResourcePath(),
method: aws_apigateway.AccessLogField.contextHttpMethod(),
error: aws_apigateway.AccessLogField.contextErrorMessage(),
validationError: aws_apigateway.AccessLogField.contextErrorValidationErrorString(),
status: aws_apigateway.AccessLogField.contextStatus()
})),
accessLogDestination: new aws_apigateway.LogGroupLogDestination(apigwLogGroup)
},
})
There is an option to activate Full Request and Response Logs in the CDK, dataTraceEnabled flag in the deployOptions.
const api = new apigateway.RestApi(this, 'books', {
cloudWatchRole: true,
deployOptions: {
loggingLevel: apigateway.MethodLoggingLevel.INFO,
dataTraceEnabled: true
}
})