honkskillet
honkskillet

Reputation: 3137

how to see console.log in AWS lambda functions

Where do you see the console.log() calls made inside of AWS Lambda functions? I looked at AWS Cloud Watch event log and didn't see them there. Is there a CLI way to see them?

Upvotes: 4

Views: 6542

Answers (2)

Eric M. Johnson
Eric M. Johnson

Reputation: 7337

console.log() should definitely end up in the CloudWatch logs for your function. You should be able to find the correct log group in the web console interface for your function under the Monitoring tab - Jump to Logs. Note that you will have a different log stream for each invocation of your function, and there may be a delay between logs being written and logs showing up in a stream, so be patient.

It's possible you do not have the IAM permissions to create log groups or write to log streams. Ashan has provided links on how to fix that.

Additionally, you can use the awslogs tool to list groups/streams, as well as to download or tail groups/streams:

  • To list available groups: awslogs groups
  • To list available streams in group app/foo: awslogs streams app/foo
  • To "tail -f" all streams from a log group app/foo: awslogs get app/foo ALL --watch

Upvotes: 2

Ashan
Ashan

Reputation: 19748

Make sure you the IAM role assigned to the AWS Lambda function has permission to write to CloudWatch Logs. For more information regarding the policy refer Using Identity-Based Policies (IAM Policies)for CloudWatch Logs.

In addition, you should be able to view the CloudWatch log group by clicking on the CloudWatch Logs under Add Triggers in Lambda Console.

enter image description here

Upvotes: 0

Related Questions