Should I log exceptions when raising or when catching?
When an error occurs, I see two possible places to log it:
- Right before I raise the exception
- 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?