python-lambda icon indicating copy to clipboard operation
python-lambda copied to clipboard

Logging configuration

Open stevezau opened this issue 9 years ago • 2 comments

Hi, When running invoke locally it appears it does not configure logging..

Should it ?

No handlers could be found for logger "root"

stevezau avatar Dec 23 '16 02:12 stevezau

Can you elaborate?

Are you import logging?

jmeekhof avatar Jun 03 '17 02:06 jmeekhof

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

mconigliaro avatar Oct 26 '18 17:10 mconigliaro