问题描述
我需要能够查看 AWS API网关
上的调用日志。当我从Gateway的仪表板中执行呼叫时,可以在 Logs
部分下看到它们。
如何查看他们用于外部通话(例如:使用 curl
进行的通话)?
我尝试启用CloudWatch,但只能看到指标,而不是实际的日志消息。
最不可能在CloudWatch中看到API网关日志的原因日志是您尚未指定IAM角色的ARN,该API使API Gateway能够将信息写入CloudWatch Logs。
然后,您需要在每个阶段上明确启用日志记录。您无需重新部署API,只需保存。
此处的详细说明:
I need to be able to see the logs for my calls on AWS API Gateway
. When I perform the calls from within Gateway's Dashboard I can see them under the Logs
section.
How can I see them for external call (e.g.: calls made using curl
)?
I tried enabling CloudWatch but I can only see the metric, and not the actual log messages.
The most likely reason for not being able to see API Gateway logs in CloudWatch logs is that you haven't specified the ARN of an IAM role that enables API Gateway to write information to CloudWatch Logs.
You then need to explicitly enable logging on each Stage. You don't need to (re)Deploy the API, just Save.
Detailed instructions here: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-stage-settings.html#how-to-stage-settings-console
Once enabled you will get a log group named "/aws/apigateway/welcome" with a log line confirming logs are enabled.
这篇关于如何查看外部呼叫的AWS Gateway日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!