8👍
The following works for me in the settings module.
It adds the environment variable DJANGO_ENVDIR
to every message being sent.
from raven.contrib.django.client import DjangoClient as RavenDjangoClient
class SentryDjangoClient(RavenDjangoClient):
def build_msg(self, *args, **kwargs):
data = super(RavenDjangoClient, self).build_msg(*args, **kwargs)
data['tags']['ENVDIR'] = os.environ.get('DJANGO_ENVDIR', 'unset')
return data
if get_env_var('SENTRY_DSN', False):
RAVEN_CONFIG = {
'dsn': get_env_var('SENTRY_DSN'),
# NOTE: timeout set via DSN
}
SENTRY_CLIENT = 'project.settings.base.SentryDjangoClient'
You need to adjust the SENTRY_CLIENT setting, according to where you put the SentryDjangoClient class, which extends the build_msg
method.
0👍
You could assign a different name to the logger, before logging the message. That would allow you to filter by the “logger” in the Sentry server.
- [Django]-Equals sign in django-registration activation url
- [Django]-Is apache necessary while we have python's built-in SimpleHttpServer
- [Django]-Output log file through Ajax in Django
- [Django]-How to delete ONLY m2m relation?
Source:stackexchange.com