70408/how-can-i-log-a-python-error-with-debug-information
I am printing Python exception messages to a log file with logging.error:
import logging try: 1/0 except ZeroDivisionError as e: logging.error(e) # ERROR:root:division by zero
Is it possible to print more detailed information about the exception and the code that generated it than just the exception string?
Hii,
Using exc_info options may be better, to allow you to choose the error level (if you use exception, it will always be at the error level):
try: # do something here except Exception as e: logging.critical(e, exc_info=True)
Hope this works!!
Good question. I actually was stuck with ...READ MORE
Hey, Web scraping is a technique to automatically ...READ MORE
Hi, @There, Try this: Rollback pip to an older ...READ MORE
yes, you can use "os.rename" for that. ...READ MORE
suppose you have a string with a ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
Hii, In most applications, you won't be calling ...READ MORE
Hii, You need to call os.path.realpath on __file__, so that when __file__ is ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.