Skip to content

Exceptions can be logged twice in Django 1.3 #210

@tomaszzielinski

Description

@tomaszzielinski

This is a bit misleading: http://readthedocs.org/docs/sentry/en/latest/config/index.html#integration-with-logging
due to the problem described in this comment: https://github.com/dcramer/django-sentry/issues/193#issuecomment-1584249

In Django 1.3 we have the following:

https://code.djangoproject.com/browser/django/tags/releases/1.3/django/core/handlers/base.py#L152
https://code.djangoproject.com/browser/django/tags/releases/1.3/django/core/handlers/base.py#L166
https://code.djangoproject.com/browser/django/tags/releases/1.3/django/core/handlers/base.py#L180

  • as you can see, signals.got_request_exception.send() is always paired with handle_uncaught_exception(). And the latter function logs the caught exception:

https://code.djangoproject.com/browser/django/tags/releases/1.3/django/core/handlers/base.py#L205

And because django-sentry wires itself to signals.got_request_exception():

https://github.com/dcramer/django-sentry/blob/master/sentry/client/models.py#L61

  • if one adds SentryHandler to one of django.request, django or root loggers, the exception is logged twice.

Now, this is not the end of the world, but would be good to fix, e.g. by adding configuration option to prevend django-sentry from wiring to signals.got_request_exception.send().

I will prepare a patch (unless someone else is quicker or eager to do that :)) but some short discussion on this would be great to have first - maybe I overlooked a solution or a better approach exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions