Bases: object
factory methods for access log format.
infused
Example:
log_group = logs.LogGroup(self, "ApiGatewayAccessLogs") apigateway.RestApi(self, "books", deploy_options=apigateway.StageOptions( access_log_destination=apigateway.LogGroupLogDestination(log_group), access_log_format=apigateway.AccessLogFormat.custom(f"{apigateway.AccessLogField.contextRequestId()} {apigateway.AccessLogField.contextErrorMessage()} {apigateway.AccessLogField.contextErrorMessageString()}") ) )
Methods
Output a format string to be used with CloudFormation.
str
Static Methods
Generate Common Log Format.
Custom log format.
You can create any log format string. You can easily get the $ context variable by using the methods of AccessLogField.
format (str
)
Example:
apigateway.AccessLogFormat.custom(JSON.stringify({ "request_id": apigateway.AccessLogField.context_request_id(), "source_ip": apigateway.AccessLogField.context_identity_source_ip(), "method": apigateway.AccessLogField.context_http_method(), "user_context": { "sub": apigateway.AccessLogField.context_authorizer_claims("sub"), "email": apigateway.AccessLogField.context_authorizer_claims("email") } }))
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.
caller (bool
) â If this flag is enabled, the principal identifier of the caller will be output to the log.
http_method (bool
) â If this flag is enabled, the http method will be output to the log.
ip (bool
) â If this flag is enabled, the source IP of request will be output to the log.
protocol (bool
) â If this flag is enabled, the request protocol will be output to the log.
request_time (bool
) â If this flag is enabled, the CLF-formatted request time((dd/MMM/yyyy:HH:mm:ss +-hhmm) will be output to the log.
resource_path (bool
) â If this flag is enabled, the path to your resource will be output to the log.
response_length (bool
) â If this flag is enabled, the response payload length will be output to the log.
status (bool
) â If this flag is enabled, the method response status will be output to the log.
user (bool
) â If this flag is enabled, the principal identifier of the user will be output to the log.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4