Aug-10-2021, 09:56 AM
It looks there is some misunderstanding how logging works.
You need to handle the error with
print(1/0)
produce unhandled error and program ends with the traceback you show.You need to handle the error with
try/except/else/finally
block (note, not all 4 are mandatory) and only if you want you can log something, e.g.import os, logging, logging.handlers handler = logging.handlers.WatchedFileHandler(os.environ.get("LOGFILE", "E:/Faults.log")) formatter = logging.Formatter(logging.BASIC_FORMAT) handler.setFormatter(formatter) root = logging.getLogger() root.setLevel(os.environ.get("LOGLEVEL", "DEBUG")) root.addHandler(handler) logging.debug("Logger check") try: print(1/0) except ZeroDivisionError: logging.critical('Division by zero')
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs