Duplicated log lines using Python in AWS Lambda

The short version:

logname = 'processing'
formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger = logging.getLogger(logname)
logger.setLevel(logging.DEBUG)
logger.handlers = [] # === Make sure to add this line
logger.addHandler(handler)
logger.propagate = False # === and this line

For details, check out this link

Leave a Reply

Your email address will not be published. Required fields are marked *