Skill 4.2.2
Implement an effective logging strategy to record application behavior and state
Key Concepts
Use log levels (DEBUG, INFO, WARN, ERROR) and set the level per environment, keeping production at INFO or WARN; Lambda's advanced logging controls let you set the application and system log levels and JSON format without code changes. Log key business events and every error with context such as request ID, user or tenant ID and relevant parameters.
Set retention periods on log groups to control cost, since the default is never to expire. Never log secrets or personal data, and use CloudWatch Logs data protection policies as a safety net. Centralise logs from multiple accounts with cross-account log sharing or subscriptions.