Best way to log a Python exception -
i'm printing exceptions log file with:
try: # coode in here except exception, e: logging.error(e) could printing more information exception , code generated exception string? things line numbers or stack traces great.
logger.exception that.
for example:
import logging try: 1/0 except exception e: logging.exception("message") output:
error:root:message traceback (most recent call last): file "<stdin>", line 2, in <module> zerodivisionerror: integer division or modulo 0 @paulo cheque notes, "be aware in python 3 must call logging.exception method inside except part. if call method in arbitrary place may bizarre exception. docs alert that."
Comments
Post a Comment