0

I have my Django instance configured with

    "mail_admins": {
        "level": "ERROR",
        "class": "django.utils.log.AdminEmailHandler",
    },

When I get logging.error() messages, I don't know where they were generated and would like to in order to possibly change their level to squelch noise.

Adding include_html=True did not add a stack trace.

I've looked through AdminEmailHandler and I haven't found an obvious way to hook this capability in.

rrauenza
  • 6,285
  • 4
  • 32
  • 57

1 Answers1

0

This doesn't seem that straightforward. First, prior to Python 3.7 there isn't a supported way to make a traceback. Prior to Django 3.1, DEFAULT_EXCEPTION_REPORTER doesn't exist.

The smarter way to do this is probably just to track the line number with logging.Formatter.

rrauenza
  • 6,285
  • 4
  • 32
  • 57