{"action":"created","issue":{"url":"https://api.github.com/repos/lamby/django-slack/issues/40","repository_url":"https://api.github.com/repos/lamby/django-slack","labels_url":"https://api.github.com/repos/lamby/django-slack/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/lamby/django-slack/issues/40/comments","events_url":"https://api.github.com/repos/lamby/django-slack/issues/40/events","html_url":"https://github.com/lamby/django-slack/issues/40","id":139329300,"number":40,"title":"Error when trying to log DisallowedHost error","user":{"login":"joshblum","id":1144020,"avatar_url":"https://avatars.githubusercontent.com/u/1144020?v=3","gravatar_id":"","url":"https://api.github.com/users/joshblum","html_url":"https://github.com/joshblum","followers_url":"https://api.github.com/users/joshblum/followers","following_url":"https://api.github.com/users/joshblum/following{/other_user}","gists_url":"https://api.github.com/users/joshblum/gists{/gist_id}","starred_url":"https://api.github.com/users/joshblum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshblum/subscriptions","organizations_url":"https://api.github.com/users/joshblum/orgs","repos_url":"https://api.github.com/users/joshblum/repos","events_url":"https://api.github.com/users/joshblum/events{/privacy}","received_events_url":"https://api.github.com/users/joshblum/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-03-08T16:48:32Z","updated_at":"2016-03-09T14:45:55Z","closed_at":"2016-03-08T16:58:07Z","body":"I'm trying to log `DisallowedHost` errors to slack with the following logging config:\r\n```\r\n[...]\r\n    'handlers': {\r\n        'slack': {\r\n            'level': 'ERROR',\r\n            'filters': ['require_debug_false'],\r\n            'class': 'django_slack.log.SlackExceptionHandler',\r\n        },\r\n     },\r\n     'loggers': {\r\n        'django.security.DisallowedHost': {\r\n            'handlers': ['slack'],\r\n            'propagate': False,\r\n           'level': 'ERROR',\r\n        },\r\n}\r\n[...]\r\n```\r\nThe problem is that when trying to get the error traceback, the same exception is raised (`django.core.exceptions.DisallowedHost`)\r\n\r\n```\r\n[...]\r\ndjango.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'localhost'. You may need to add 'localhost' to ALLOWED_HOSTS.\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.4/wsgiref/handlers.py\", line 137, in run\r\n    self.result = application(self.environ, self.start_response)\r\n  File \"/virtualenv/lib/python3.4/site-packages/whitenoise/base.py\", line 119, in __call__\r\n    return self.application(environ, start_response)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py\", line 189, in __call__\r\n    response = self.get_response(request)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py\", line 204, in get_response\r\n    'request': request\r\n  File \"/usr/lib/python3.4/logging/__init__.py\", line 1303, in error\r\n    self._log(ERROR, msg, args, **kwargs)\r\n  File \"/usr/lib/python3.4/logging/__init__.py\", line 1409, in _log\r\n    self.handle(record)\r\n  File \"/usr/lib/python3.4/logging/__init__.py\", line 1419, in handle\r\n    self.callHandlers(record)\r\n  File \"/usr/lib/python3.4/logging/__init__.py\", line 1481, in callHandlers\r\n    hdlr.handle(record)\r\n  File \"/usr/lib/python3.4/logging/__init__.py\", line 853, in handle\r\n    self.emit(record)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django_slack/log.py\", line 53, in emit\r\n    reporter.get_traceback_text(),\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/views/debug.py\", line 390, in get_traceback_text\r\n    return t.render(c)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/base.py\", line 209, in render\r\n    return self._render(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/base.py\", line 201, in _render\r\n    return self.nodelist.render(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/base.py\", line 903, in render\r\n    bit = self.render_node(node, context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/debug.py\", line 79, in render_node\r\n    return node.render(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/defaulttags.py\", line 329, in render\r\n    return nodelist.render(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/base.py\", line 903, in render\r\n    bit = self.render_node(node, context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/debug.py\", line 79, in render_node\r\n    return node.render(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/debug.py\", line 89, in render\r\n    output = self.filter_expression.resolve(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/base.py\", line 647, in resolve\r\n    obj = self.var.resolve(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/base.py\", line 787, in resolve\r\n    value = self._resolve_lookup(context)\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/template/base.py\", line 847, in _resolve_lookup\r\n    current = current()\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/http/request.py\", line 151, in build_absolute_uri\r\n    host=self.get_host(),\r\n  File \"/virtualenv/lib/python3.4/site-packages/django/http/request.py\", line 101, in get_host\r\n    raise DisallowedHost(msg)\r\ndjango.core.exceptions.DisallowedHost: Invalid HTTP_HOST header\r\n```\r\n\r\nAny ideas how to avoid raising this when trying to log the error?"},"comment":{"url":"https://api.github.com/repos/lamby/django-slack/issues/comments/194325811","html_url":"https://github.com/lamby/django-slack/issues/40#issuecomment-194325811","issue_url":"https://api.github.com/repos/lamby/django-slack/issues/40","id":194325811,"user":{"login":"joshblum","id":1144020,"avatar_url":"https://avatars.githubusercontent.com/u/1144020?v=3","gravatar_id":"","url":"https://api.github.com/users/joshblum","html_url":"https://github.com/joshblum","followers_url":"https://api.github.com/users/joshblum/followers","following_url":"https://api.github.com/users/joshblum/following{/other_user}","gists_url":"https://api.github.com/users/joshblum/gists{/gist_id}","starred_url":"https://api.github.com/users/joshblum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshblum/subscriptions","organizations_url":"https://api.github.com/users/joshblum/orgs","repos_url":"https://api.github.com/users/joshblum/repos","events_url":"https://api.github.com/users/joshblum/events{/privacy}","received_events_url":"https://api.github.com/users/joshblum/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T14:45:55Z","updated_at":"2016-03-09T14:45:55Z","body":"Thanks so much for helping! \r\n\r\nIs there a reason we don't try a best effort to give more information if the `get_traceback_text` call fails? Is there useful information in the `exc_info` object?\r\n"}}