Skip to content

Lambda "print"/logging not appearing in CloudWatch (AWS/TypingMind integration)

0

I have an AWS Free Tier account. I created Lambda functions (Python 3.12) in us-east-2 (Ohio) and us-east-1 (N. Virginia), attaching the AWSLambdaBasicExecutionRole to every function.

My code is a minimal handler:

python

import logging logger = logging.getLogger() logger.setLevel(logging.DEBUG)

def lambda_handler(event, context): logger.debug("HELLO FROM LAMBDA") return {"statusCode": 200, "body": "hello"}

I Deploy and use the “Test” button in the Lambda console. The function returns successfully.

However: No new log groups are created in CloudWatch Logs for new functions. For the original /aws/lambda/cci-onet-librarian-api log group (created yesterday), only INIT/START/END/REPORT log lines show up. I never see any user print/logger.debug output. I verified that the execution role includes only AWSLambdaBasicExecutionRole, which grants logs:CreateLogGroup and related permissions. I also tried a more permissive inline policy with logs:*, to no effect. I am not in an AWS Organization, so there should not be any SCPs restricting actions.

Why are user log lines (print/logger.debug) never written, and why are new log groups never created anymore, even after running Deploy+Test (which should always auto-create a group)? Is this a new restriction on Free Tier, or could there be a service/account misconfiguration?

My goal is to use this Lambda successfully as an API backend for TypingMind (AI chat platform), but I can’t proceed with integration or debugging until CloudWatch logs are working.

Screenshots and details available if needed.

3 Answers
0

logger.Debug probably won't appear in CloudWatch but print statements will appear. Regardless, when lambda is invoked, the invocation statement will appear in CloudWatch. If you don't see a log group, make sure you are checking for log groups in the correct region and that you have permissions to create it. Also, under Monitor section in Lambda, it should have a link to CloudWatch.

EXPERT

answered a year ago

  • "Even when running the default 'Test' on a new Lambda with AWSLambdaBasicExecutionRole, the log group does not get created in any region. Clicking 'View logs in CloudWatch' from Lambda's Monitor tab confirms log group missing, with error: Log group does not exist. Role permissions look correct; this occurs even for a basic hello-world Python function. What account, free tier, or root policy could block log group creation?"

0

"Even when running the default 'Test' on a new Lambda with AWSLambdaBasicExecutionRole, the log group does not get created in any region. Clicking 'View logs in CloudWatch' from Lambda's Monitor tab confirms log group missing, with error: Log group does not exist. Role permissions look correct; this occurs even for a basic hello-world Python function. What account, free tier, or root policy could block log group creation?"

answered a year ago

  • sorry I meant that as a comment to the previous answer...

0

There are several potential reasons why your Lambda function logs aren't appearing in CloudWatch Logs:

  1. CloudWatch Logs Quota Limits: Your AWS account may have reached CloudWatch Logs quota limits, causing CloudWatch to throttle function logging. When this happens, some logs may not appear in CloudWatch Logs.

  2. Log Rate Exceeding Processing Capacity: If your function outputs logs at too high a rate for Lambda to process them (exceeding 2 MB/s for a single log stream), Lambda may drop logs to prevent slowing down your function's execution.

  3. Permissions Issues: While you've attached the AWSLambdaBasicExecutionRole, which should provide the necessary permissions (logs:CreateLogGroup, logs:CreateLogStream, and logs:PutLogEvents), there might be an issue with how the role is attached or configured.

  4. Log Format Configuration: For Python functions, note that using Python print statements will only send logs to CloudWatch in plain text format. Your code is using the logging module correctly, which should work.

  5. Delayed Log Appearance: There can be a delay of 5-10 minutes before logs appear in CloudWatch Logs. Have you waited long enough after function execution?

  6. Log Level Configuration: Check if you have any log level filtering configured on your Lambda function. The ApplicationLogLevel setting can filter logs based on their severity level.

To troubleshoot:

  1. Verify that the execution role is correctly attached to your Lambda function
  2. Try using both print statements and logger calls to see if either appears
  3. Wait at least 10 minutes after function execution to check for logs
  4. Check if you're hitting any CloudWatch Logs service quotas
  5. Try creating a new function with a different name in case there's an issue with the specific log group

If none of these solutions work, you might need to contact AWS Support as there could be an account-specific issue.
Sources
Troubleshoot execution issues in Lambda - AWS Lambda
Configuring CloudWatch log groups - AWS Lambda
Log and monitor Python Lambda functions - AWS Lambda
Sending Lambda function logs to CloudWatch Logs - AWS Lambda
LoggingConfig - AWS Lambda

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.