python-lambda
python-lambda copied to clipboard
Logging configuration
Hi, When running invoke locally it appears it does not configure logging..
Should it ?
No handlers could be found for logger "root"
Can you elaborate?
Are you import logging?
It looks like something else already configured the root logger (both locally and on AWS), so I made my own, and that seemed to fix it:
logger = logging.getLogger('handler')
logger.handlers = []
logger.setLevel(getattr(logging, os.environ['LOG_LEVEL'], logging.NOTSET))
log_handler = logging.StreamHandler()
log_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
logger.addHandler(log_handler)
logger.propagate = False
More info here: https://forum.serverless.com/t/python-lambda-logging-duplication-workaround/1585/6