Laurent Jalbert Simard Laurent Jalbert Simard -4 years ago 85
Python Question

Is it possible to use Django's SafeExceptionReporterFilter with something else than the AdminEmailHandler?

I'm trying to filter out sensitive informations using Django's

. I thought prepending these annotations over a the few specific fonctions would be enough, but it doesn't work. I've set breakpoint inside
and it only breaks when being called from the
and not the other handlers. What am I missing ?

Answer Source

Even if you use the SafeExceptionReporterFilter, exceptions will still contains sensitive data (e.g. your Server's ENV variables and other runtime data).

To avoid exposing sensitive data, you should not use this filter. Instead, write your own Exception Handler Middleware and selectively(recursively?) fetch yourself the data you want in the logs.

See sys.exc_info on how to obtain exception's traceback and how to use it for your needs.

Even if you go with a CustomHandler you'll be limited with a specific handler and as far as I know, third-parties handlers won't use the SafeExceptionReporterFilter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download