Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 429 Bytes

20220910095028.md

File metadata and controls

20 lines (16 loc) · 429 Bytes

logging exceptions

How to log Python errors with debug information?

logging.exception() will output a stack trace alongside the error message you specify:

>>> import logging
>>> try:
...     1/0
... except ZeroDivisionError:
...     logging.exception("message")
...
ERROR:root:message
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero

#logging #exceptions