Sentry support #58

Open
dbrgn opened this Issue Mar 27, 2013 · 2 comments

2 participants

@dbrgn

Is it possible to integrate dajax/dajaxice with Sentry/Raven? I tried to add a logger, but nothing seems to get sent to my server, even though I triggered an error in the ajax view in production mode.

My logging config:

LOGGING['root'] = {
    'level': 'WARNING',
    'handlers': ['sentry'],
}
LOGGING['handlers']['sentry'] = {
    'level': 'ERROR',
    'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
}
LOGGING['loggers']['sentry.errors'] = {
    'level': 'DEBUG',
    'handlers': ['console'],
    'propagate': False,
}
LOGGING['loggers']['raven'] = {
    'level': 'DEBUG',
    'handlers': ['console'],
    'propagate': False,
}
LOGGING['loggers']['dajaxice'] = {
    'handlers': ['sentry'],
    'level': 'WARNING',
    'propagate': False,
}
@h3
h3 commented May 23, 2013

I managed to make it work, but for some reasons it doesn't seem to work once deployed in production..

Here's my config:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        },
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'sentry': {
            'level': 'ERROR',
            'class': 'raven.contrib.django.handlers.SentryHandler',
        },
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console':{
            'level':'DEBUG',
            'class':'logging.StreamHandler',
            'formatter': 'simple'
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins', 'console', 'sentry'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'dajaxice': {
            'handlers': ['console', 'sentry'],
            'level': 'WARNING',
            'propagate': False,
        },
        'sentry.errors': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
    }
}
@h3
h3 commented May 23, 2013

Ok .. after much more digging I found out what's going on.

This is a problem with dajaxice, not sentry :)

This is caused by dajaxice not logging the traceback. An issue about this problem is open since 4 months ..

jorgebastida/django-dajaxice#88

I forked it and will make a pull request, but the development of dajaxice seems quite slow.. I don't know if it will ever get merged.

Meanwhile my fixed repo is available here:

https://github.com/h3/django-dajaxice/tree/88_logging_traceback_fix

@h3 h3 referenced this issue in jorgebastida/django-dajaxice May 23, 2013
Open

Fixed issue #88 about logging traceback #107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment