raven - sentry + django = No servers configured, and sentry not installed. Cannot send message

StackOverflow https://stackoverflow.com/questions/11136207

  •  16-06-2021
  •  | 
  •  

Question

I have a sentry server that works ok.

raven test <dnstoserver> -> Sending a test message... success!

I have a dev machine with django 1.3 and raven 1.93. In the django project I have this:

setting.py:

SENTRY_KEY=<secretkey>
SENTRY_DNS=<dnstoserver>

INSTALLED_APPS = (
    'bar',
    'foo',
    'raven.contrib.django',
)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
    },
    'handlers': {
        'sentry': {
            'level': 'ERROR',
            'class': 'raven.contrib.django.handlers.SentryHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'django.db.backends': {
            'level': 'ERROR',
            'handlers': ['console'],
            'propagate': False,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['console', 'sentry'],
            'propagate': False,
        },        
    },
}

Mind the absence of 'sentry' in the installed_apps. This is intentionally, since sentry is the server and should not be on a client!

views.py (in a view):

import logging
logger = logging.getLogger("raven")
logger.error("test")

When I run the view I get on the console:

No servers configured, and sentry not installed. Cannot send message

Why, and how to fix?

Was it helpful?

Solution

Were you really setting SENTRY_DNS or SENTRY_DSN?

When you set SENTRY_DSN the instantiation of the major config variables happens automatically (including SENTRY_SERVERS, SENTRY_PUBLIC_KEY, SENTRY_SECRET_KEY, and SENTRY_PROJECT)

OTHER TIPS

The problem was in the construction of the raven DjangoClient. It did not get passed any servers, and couldn't find sentry config to steal that config from. I added in the settings.py:

SENTRY_SERVERS=<dnstoserver>

Console now outputs this every time raven is called:

INFO 2012-06-21 05:33:19,831 base 4323 140735075462336 Configuring Raven for host: <dnstoserver>

But it works like a charm! Messages in sentry...

BTW. for all the undocumented settings take a look in raven.contrib.django.models.get_client()

I suggest to use:

SENTRY_DSN = 'http://user:password@<domain>:<port>/<project_id>'

And in APPS_INSTALLED add:

'raven.contrib.django.raven_compat'

Also take a look at this guide: http://code.fetzig.at/post/18607051916/sentry-and-raven-setup-for-django-projects

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top