Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Created May 12, 2021 15:47
Show Gist options
  • Save Abhayparashar31/6586bc0b925814e3340119cb8403320f to your computer and use it in GitHub Desktop.
Save Abhayparashar31/6586bc0b925814e3340119cb8403320f to your computer and use it in GitHub Desktop.
import logging
a = 10
b = 0
try:
c = a / b
except Exception as e:
logging.error("Exception Occurred", exc_info=True) ## At default it is True
----------------------------------CONSOLE OUTPUT------------------------
ERROR:root:Exception Occurred ## If exc_info=False then only this message will print
Traceback (most recent call last):
File "C:\Users\abhay\Desktop\ds\python\advance_concepts\logging_code.py", line 5, in <module>
c = a / b
ZeroDivisionError: division by zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment