What is one cause of this?
The developers did not enable log messages for this Lambda function.
The Lambda function’s role does not include permissions to create CloudWatch Logs items.
The Lambda function raises an exception before the first log statement has been reached.
The Lambda functions creates local log files that have to be shipped to CloudWatch Logs first before becoming visible.
Explanations:
AWS Lambda automatically sends logs to CloudWatch Logs; there is no separate configuration to enable logging. However, if logging statements are not included in the code, no logs will appear.
If the Lambda function’s execution role does not have the necessary permissions to write logs to CloudWatch Logs (specifically, thelogs:CreateLogGroup,logs:CreateLogStream, andlogs:PutLogEventspermissions), then log messages will not be recorded. This is a common issue that can prevent logs from appearing.
If the Lambda function raises an exception before the first log statement, it would typically still log the error message. AWS Lambda logs function invocations and any errors that occur, so some logs would still be generated, even if they do not include expected log messages.
AWS Lambda does not create local log files that need to be shipped to CloudWatch. Instead, it streams logs directly to CloudWatch Logs in real-time, meaning they should appear almost immediately after the function is executed.