import logging
logger = logging.getLogger(__name__)
logger.addHandler(logging.FileHandler(filename='logloglog.log'))
logger.critical('A!')
for handler in logger.handlers:
handler.close()
logger.addHandler(logging.FileHandler(filename='logloglog.log'))
logger.critical('B!')
I am trying to understand why the above code logs B! string in logloglog.log file twice. It confuses me, since I log both A! and B! only one time. Can you help me?