AccessLogFormat

class aws_cdk.aws_apigateway.AccessLogFormat(*args, **kwargs)

Bases: object

factory methods for access log format.

Methods

to_string()

Output a format string to be used with CloudFormation.

Return type

str

Static Methods

classmethod clf()

Generate Common Log Format.

Return type

AccessLogFormat

classmethod custom(format)

Custom log format.

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

Parameters

format (str) –

Example:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
custom(JSON.stringify(
    request_id=AccessLogField.context_request_id(),
    source_ip=AccessLogField.context_identity_source_ip(),
    method=AccessLogFiled.context_http_method(),
    user_context={
        "sub": AccessLogField.context_authorizer_claims("sub"),
        "email": AccessLogField.context_authorizer_claims("email")
    }
))
Return type

AccessLogFormat

classmethod json_with_standard_fields(*, caller, http_method, ip, protocol, request_time, resource_path, response_length, status, user)

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.

Parameters
  • 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.

Return type

AccessLogFormat