Python docs point out that you should use exception
method inside an exception handler. It automatically add the stack trace and logs the message as ERROR
level.
def main_function():
try:
process()
handle()
finish()
except Exception as ex:
logger.error("Context message here")
def main_function():
try:
process()
handle()
finish()
except Exception:
logger.exception("Context message here")