Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows compatibility
#12
My attempts at logging have not been very successful.
I have the following code which concludes with an intentional attempt to print a divide-by-zero result to test the logger:

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")

print(1/0)
Running this gives the following Console result:

Error:
Traceback (most recent call last): File "E:\FaultLogger.py", line 12, in <module> print(1/0) ZeroDivisionError: division by zero
But the Fault.log file only records :

Output:
DEBUG:root:Logger check
but the debug does not recognise print(1/0) as a ZeroDivisionError.

It seems simple, but something is clearly wrong.

Any suggestions welcome!

Thanks
ASTRIKOR
buran write Aug-10-2021, 09:18 AM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Reply


Messages In This Thread
Windows compatibility - by Astrikor - Aug-03-2021, 08:52 AM
RE: Windows compatibility - by Larz60+ - Aug-03-2021, 09:49 AM
RE: Windows compatibility - by Astrikor - Aug-03-2021, 10:12 AM
RE: Windows compatibility - by DeaD_EyE - Aug-03-2021, 10:27 AM
RE: Windows compatibility - by supuflounder - Aug-03-2021, 10:38 AM
RE: Windows compatibility - by Astrikor - Aug-03-2021, 11:39 AM
RE: Windows compatibility - by Astrikor - Aug-04-2021, 08:31 AM
RE: Windows compatibility - by jefsummers - Aug-04-2021, 11:14 AM
RE: Windows compatibility - by Astrikor - Aug-04-2021, 12:18 PM
RE: Windows compatibility - by ndc85430 - Aug-04-2021, 12:40 PM
RE: Windows compatibility - by Astrikor - Aug-04-2021, 03:02 PM
RE: Windows compatibility - by Astrikor - Aug-10-2021, 09:03 AM
RE: Windows compatibility - by buran - Aug-10-2021, 09:56 AM
RE: Windows compatibility - by Astrikor - Aug-10-2021, 10:03 AM
RE: Windows compatibility - by ndc85430 - Aug-10-2021, 10:14 AM
RE: Windows compatibility - by buran - Aug-10-2021, 10:21 AM
RE: Windows compatibility - by Astrikor - Aug-10-2021, 10:55 AM
RE: Windows compatibility - by buran - Aug-10-2021, 11:03 AM
RE: Windows compatibility - by Astrikor - Aug-10-2021, 11:27 AM
RE: Windows compatibility - by Luckk - Aug-10-2021, 01:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  deactivate compatibility pop up with excel files Krszt 0 1,945 Mar-19-2019, 06:39 AM
Last Post: Krszt
  Check Python version from inside script? Run Pythons script in v2 compatibility mode? pstein 2 9,875 Jul-07-2017, 08:59 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020