I agree, if you do the logging after a crash, you don’t log the crash, and the logging itself could fail.
I wrap most http endpoint in a try-except and log or email myself the traceback when there is an error. Here I describe how I do that in an uplink: How to handle unexpected disconnect in Uplink program? - #4 by stefano.menci
Anvil allows also to define a default error handler, but I have never tried it with http endpoints.