Lambda that logs to CloudWatch - ActoKids/web-crawler GitHub Wiki

Lambda function that logs message to CloudWatch

I have created a lambda function that logs to CloudWatch.

Here is the function created in the AWS lambda panel:

and here is the code:

import json
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)

def lambda_handler(event, context):
    logging.info('Nork Lambda Test')
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

the function logs a message that is recorded in CloudWatch as shown here: as you can see, CloudWatch has logged all of the times I have run the function.