{"id":5675,"date":"2014-04-05T04:21:04","date_gmt":"2014-04-05T04:21:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/05\/sentry-raven-and-django-celery-collection-of-common-programming-errors\/"},"modified":"2014-04-05T04:21:04","modified_gmt":"2014-04-05T04:21:04","slug":"sentry-raven-and-django-celery-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/05\/sentry-raven-and-django-celery-collection-of-common-programming-errors\/","title":{"rendered":"sentry, raven and django celery-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/PUmKs.jpg?s=32&amp;g=1\" \/><br \/>\nTimmy O&#8217;Mahony<\/p>\n<p>Now that <code>django-sentry<\/code> has become a standalone server (and is fantastic) I&#8217;m trying to port my apps over to use it.<\/p>\n<p>I have set up a standalone server configured a django application to log using django 1.3&#8217;s logging dictionary conf as per the raven docs. I can&#8217;t seem to get any celery tasks to log to the sentry server (they do get printed out to the console though).<\/p>\n<p>I&#8217;m not really sure what I should be doing? I have included <code>raven.contrib.django.celery<\/code> in my `INSTALLED_APPS&#8217;.<\/p>\n<p>Uncaught exceptions are being sent to sentry, as are custom logging message via:<\/p>\n<pre><code>import logging\nlogger = logging.getLogger(__name__)\n...\nlogger.info(\"Logged Message\")    \n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3b9d20e6e9c3fac02471ba541ebecfaa?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntghw<\/p>\n<p>You need add this:<\/p>\n<pre><code>'celery': {\n        'level': 'WARNING',\n        'handlers': ['sentry'],\n        'propagate': False,\n    },\n<\/code><\/pre>\n<p>To your <code>loggers<\/code> in the variable <code>LOGGING<\/code> in your settings.<\/p>\n<p>something like:<\/p>\n<pre><code># the site admins on every HTTP 500 error.\n# See http:\/\/docs.djangoproject.com\/en\/dev\/topics\/logging for\n# more details on how to customize your logging configuration.\nLOGGING = {\n    'version': 1,\n    'disable_existing_loggers': True,\n    'root': {\n        'level': 'WARNING',\n        'handlers': ['sentry'],\n    },\n    'formatters': {\n        'verbose': {\n            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %    (message)s'\n        },\n    },\n    'handlers': {\n        'sentry': {\n            'level': 'DEBUG',\n            'class': 'raven.contrib.django.handlers.SentryHandler',\n        },\n        'console': {\n            'level': 'DEBUG',\n            'class': 'logging.StreamHandler',\n            'formatter': 'verbose'\n        }\n    },\n    'loggers': {\n        'django.db.backends': {\n            'level': 'ERROR',\n            'handlers': ['console'],\n            'propagate': False,\n        },\n        'raven': {\n            'level': 'DEBUG',\n            'handlers': ['console'],\n            'propagate': False,\n        },\n        'sentry.errors': {\n            'level': 'DEBUG',\n            'handlers': ['console'],\n            'propagate': False,\n        },\n        'celery': {\n            'level': 'WARNING',\n            'handlers': ['sentry'],\n            'propagate': False,\n        },\n    },\n}\n<\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Timmy O&#8217;Mahony Now that django-sentry has become a standalone server (and is fantastic) I&#8217;m trying to port my apps over to use it. I have set up a standalone server configured a django application to log using django 1.3&#8217;s logging dictionary conf as per the raven docs. I can&#8217;t seem to get any celery tasks [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5675","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5675"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5675\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}