Using python Logging with AWS Lambda

As the AWS documentation suggests:

import logging
logger = logging.getLogger()
def my_logging_handler(event, context):
    logger.info('got event{}'.format(event))
    logger.error('something went wrong')

Now I made:

import logging
logging.basicConfig(level = logging.INFO)
logging.info("Hello World!")

The first snippet of code prints in the Cloud Watch console, but the second one no.

I didn't see any difference as the two snippets are using the root logger.

Python 22-03-22, 11:47 a.m. veerablog
Your essay was really helpful to me, and I want to read more of your writings in the future. I also recently discovered a fairly nice game called smash karts , which you may join and play with me if you have spare time.
25-03-22, 7:25 a.m. kanedimaria


AWS Lambda automatically monitors Lambda functions on your behalf and sends function metrics to Amazon CloudWatch. Your Lambda function comes with a CloudWatch Logs log group and a log stream for each instance of your function. The Lambda runtime environment sends details about each invocation to the log stream, and relays logs and other output from your function's code. 

25-03-22, 9:52 a.m. veerablog

This information is really helpful for us thanks for sharting this kind of post please keep suggesting such post. Myindigocard
30-03-22, 11:29 p.m. nancychandler340

Great! this is helpful, thanks for sharing.
27-04-22, 3:46 p.m. niharikaa

Log-in to answer to this question.