Getting this error and logs are not being written at all.

Cause
The role from another Lambda function was being reused, and the CloudWatch Logs write destination was configured specifically for that other Lambda function. This can be resolved by modifying the IAM policy or creating a new policy.