
Lambda functions use CloudWatch Logs as their default logging destination. This logging includes output from the Lambda service as well as output from your function code. CloudWatch Logs charges for the collection, storage and analysis of data. Customers with unmanaged retention policies and/or overly verbose logging can sometimes accrue unnecessary charges.
Consider your log retention policies. Perhaps development environment logs only need to be retained for a week or less. If production logs remain valuable for longer durations, they can eventually be pushed to lower cost tiers within S3 and removed from CloudWatch entirely. By being attentive to log retention you can reduce your cost of log storage.
You can also reduce logging costs by being attentive to your log output. For example, you may want more verbose logging in pre-production environments, where debugging information is more valuable and your log volume is lower. You may want less verbose logging in production environments where debugging information is less necessary and your log volume is much greater.
Lambda Powertools (available in Python, TypeScript, Java, and .NET) provides structured logging tools that enable you to set log levels that can be configured on a per environment basis.