handler

Add custom handler to log root level with logging.basicConfig()

Add custom handler to log root level with logging.basicConfig() Question: I am trying to build a custom log handler which sends log messages over http. However, I do not want to add the handler with addHandler() method. I want the custom handler to be configured directly at log root level with logging.basicConfig() in particular to …

Total answers: 1

No handlers could be found for logger

No handlers could be found for logger Question: I am newbie to python. I was trying logging in python and I came across No handlers could be found for logger error while trying to print some warning through logger instance. Below is the code I tried import logging logger=logging.getLogger(‘logger’) logger.warning(‘The system may break down’) And …

Total answers: 6

How to make SMTPHandler not block

How to make SMTPHandler not block Question: I installed a local SMTP server and used logging.handlers.SMTPHandler to log an exception using this code: import logging import logging.handlers import time gm = logging.handlers.SMTPHandler((“localhost”, 25), ‘[email protected]’, [‘[email protected]’], ‘Hello Exception!’,) gm.setLevel(logging.ERROR) logger.addHandler(gm) t0 = time.clock() try: 1/0 except: logger.exception(‘testest’) print time.clock()-t0 It took more than 1sec to complete, …

Total answers: 7