Exception Not Logged With Object (ARCH2159)
Key python.logging.exception-not-logged · Severity warning · Category logging
Logging only a static message inside an except drops the exception object and stack trace. This obscures the cause of the error and where it occurred.
Incorrect
Section titled “Incorrect”try: charge(order)except PaymentError: logger.error("Payment failed")Correct
Section titled “Correct”try: charge(order)except PaymentError: logger.exception("Payment failed: order=%s", order.id)Use logger.exception or pass the exception via exc_info to preserve the stack trace.