#31424: django.utils.log.AdminEmailHandler won't include stack trace when
django.server logs are propogated
-----------------------------------------+------------------------
               Reporter:  Wesley Ellis   |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  3.0
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 If I configure LOGGING such that logger has the propagate property set to
 True, the AdminEmail handler no longer contains a stack trace.

 I can reproduce with the following changes to settings.py for a brand new
 django app here:
 
https://github.com/wesleyjellis/django_bug/commit/3994f74b57ecdec95c91fc322a64ce08887de2cc

 {{{

 EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

 ADMINS = [('Test', '[email protected]')]

 LOGGING = {
     "version": 1,
     "disable_existing_loggers": False,
     "handlers": {
         "console": {
             "level": "INFO",
             "class": "logging.StreamHandler",
         },
         "mail_admins": {
             "level": "ERROR",
             "class": "django.utils.log.AdminEmailHandler",
         },
     },
     "loggers": {
         "django": {"handlers": ["console", "mail_admins"], "level":
 "INFO",},
         "django.server": {
             "handlers": ["console"],
             "level": "INFO",
             "propagate": True, # If this is True, AdminEmailHandler gets a
 record where record.request is a socket
         },
     },
 }

 }}}

 The stack trace seems to be coming from the `technical_500` templates, but
 those templates don't include the stack frame if there is no request:
 
https://github.com/django/django/blob/master/django/views/templates/technical_500.txt#L3

 The request is set here:
 https://github.com/django/django/blob/master/django/utils/log.py#L9

 But for some reason I don't understand, `record.request` is a socket
 object when {{{propagate: True}}}

 I've attached the logs for both cases here:
 
https://github.com/wesleyjellis/django_bug/commit/baa912ead8cc6f8dee1b6a69d6b5ff2cf133ef71

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31424>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.0de2d5c61e204dcf2a2e3664f8abb5ed%40djangoproject.com.

Reply via email to