On lambda, we have prepared the following scripts to verify logger operation:
import logging
deflambda_handler(event, context):
# print("Received event:" + json.dumps(event,indent=2))"
logging.basicConfig (level=logging.DEBUG)
logger = logging.getLogger()
logger.debug('test')
if__name__=='__main__':
lambda_handler (None, None)
If you do this from the command line, the log will output correctly as follows:
$python lambda_function.py
DEBUG:root:test
However, if you do this on lambda, the logger does not appear.
Is it not recorded in CloudWatch Logs?
Logging (Python)
Accessing AWS Lambda's Amazon CloudWatch Logs
© 2024 OneMinuteCode. All rights reserved.