简体   繁体   中英

How to enable Cloudwatch Logs for API Gateway using Cloudformation?

Hi I'm trying to enable Cloudwatch logs in API Gateway using Cloudformation. However, I do not find the the documentation to do so. All I can find is Logginglevel in the official documentation which doesn't seem to be the solution.

For context I'm looking to achieve this using Cloudformation but don't know how to. Please help.

从控制台手动完成

These log settings are set using MethodSetting :

  • DataTraceEnabled - is for "Log full requests..."
  • LoggingLevel is for "Log level"
  • MetricsEnabled is for "Enable detailed CloudWatch metrics"

Yaml template snippet for ApiGateway V1:

SomeApiStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      RestApiId:
        Ref: SomeApi
      DeploymentId:
        Ref: SomeApiDeployment
      StageName: some-api
      Description: Some Api stage
      MethodSettings:
        - ResourcePath: "/*"
          HttpMethod: "*"
          MetricsEnabled: true
          DataTraceEnabled: true
          LoggingLevel: "INFO"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM