如何为 http api 网关启用执行日志
How to enable execution logs for a http api gateway
我正在使用无服务器框架https://www.serverless.com/
我已经创建了一个 http api 网关 - https://www.serverless.com/framework/docs/providers/aws/events/http-api/
并像这样启用日志记录
provider:
name: aws
runtime: nodejs12.x
logs:
httpApi: true
我正在寻找执行日志,但我无法在 cloudwatch 日志组中看到它。
从这个文档 - https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/ 它建议当它是 restApi: true 时默认启用执行日志但是当你有 httpApi
时没有提到执行日志
撰写此 HTTP API 时不支持执行日志。
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html
执行日志不可用 HTTP API,因为它们仅支持 代理 与 Lambda 和 HTTP 端点的集成。因此,理想情况下,request/response 将 in/out 变为 API 网关。客户端发送的任何请求参数都可以在集成中看到 - 因此在 Lambda/HTTP 端启用登录以查看请求详细信息。
如果您想使用访问日志来解决 HTTP API 的错误,有一个新的上下文变量 $context.integrationErrorMessage
,它将以我们在执行日志中看到的类似格式给出错误消息传统的 REST API.
我正在使用无服务器框架https://www.serverless.com/
我已经创建了一个 http api 网关 - https://www.serverless.com/framework/docs/providers/aws/events/http-api/
并像这样启用日志记录
provider:
name: aws
runtime: nodejs12.x
logs:
httpApi: true
我正在寻找执行日志,但我无法在 cloudwatch 日志组中看到它。
从这个文档 - https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/ 它建议当它是 restApi: true 时默认启用执行日志但是当你有 httpApi
时没有提到执行日志撰写此 HTTP API 时不支持执行日志。
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html
执行日志不可用 HTTP API,因为它们仅支持 代理 与 Lambda 和 HTTP 端点的集成。因此,理想情况下,request/response 将 in/out 变为 API 网关。客户端发送的任何请求参数都可以在集成中看到 - 因此在 Lambda/HTTP 端启用登录以查看请求详细信息。
如果您想使用访问日志来解决 HTTP API 的错误,有一个新的上下文变量 $context.integrationErrorMessage
,它将以我们在执行日志中看到的类似格式给出错误消息传统的 REST API.