We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

CloudWatch Log Groups and Viewing Lambda Logs

When something goes wrong with your Lambda, how do you see what's happening inside the function? Debugging Lambda is trickier than a local app: you can't just attach a debugger to a process. There are ways to run Lambda locally (e.g., SAM CLI) for breakpoints, or AWS Toolkit for VSCode for IDE integration. For day-to-day debugging, though, you'll rely on logs.

Lambda automatically sends everything your function writes to stdout and stderr (including print() in Python) to Amazon CloudWatch Logs. As long as your Lambda has the basic execution role (which we attached in the deploy lesson), it can write logs. AWS creates a log group for your function and streams each run's output there.

What Lambda Logs Automatically

For every invocation, Lambda adds a few lines before and after your code's output:

  • START: Request ID and version
  • Your print() (or other stdout/stderr) output
  • END: Request ID
  • REPORT: Duration, billed duration, memory used, and so on

That REPORT line is handy for spotting slow runs or functions that are close to the memory limit.

Assignment

View your Lambda function's logs in CloudWatch using the console. They are created automatically when your function is invoked.

Cost check: A small Lambda like ours produces only a few KB per invocation. You'll stay well within the 5 GB free tier for this lesson, so expect $0.

Run and submit the tests to verify you can view your Lambda logs in CloudWatch.