Should I log exceptions when raising or when catching?
22:23 11 Jan 2026

When an error occurs, I see two possible places to log it:

  1. Right before I raise the exception
  2. When I catch the exception in a higher layer

Both seem reasonable to me, but I don’t understand the trade-offs of each approach.

  • Does logging at the raise site give better context?
  • Does logging at the catch site make more sense architecturally?
  • Is there a generally accepted best practice?
python exception