0

I have successfully installed sentry addon on heroku in a django app. I managed to track all errors and 404, following the instructions from the official docs. https://docs.sentry.io/clients/python/integrations/django/

The problem is that i cannot see log info messages, that i have manually added in my code, in the sentry dashboard.

The code in my view is the following

import logging
logger = logging.getLogger(__name__)
#somewhere in my code 
logger.debug('There was some crazy error')

And in the settings.py (I used all levels INFO, DEBUG etc)

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': 'DEBUG', # To capture more than ERROR, change to WARNING, INFO, etc.
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
            'tags': {'custom-tag': 'x'},
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'django': {
            'level': 'DEBUG',
            'handlers': ['sentry'],
            'propagate': True,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['sentry'],
            'propagate': False,
        },
        'sentry.errors': {
            'level': 'DEBUG',
            'handlers': ['sentry'],
            'propagate': False,
        },
    },
}
  • As a sanity check, can you confirm that you're seeing *errors* from your app in the Sentry project issue stream? – ehfeng Sep 06 '17 at 17:44
  • Yeah i can see error messages, and what is more i have added Sentry404CatchMiddleware class in the Middleware so i can see 404 errors, which are displayed in Sentry as INFO messages. – Michael Marinos Likouras Sep 07 '17 at 09:22

1 Answers1

1

It is porbabliy not about Django. I could not see logging.info("I am an info") shown in Sentry Dashboard, too. After checking the documentation, there are two key points about the setting.

  1. The default level of Logging is WARNING so that DEBUG/INFO will not be printed and uploaded to Sentry. Enable INFO as below
import logging
logging.basicConfig(level=logging.INFO)
## or 
logging.getLogger().setLevel(logging.INFO)
  1. Using latest sentry_sdk as below, do not forget the integrations part
sentry_logging = LoggingIntegration(event_level=logging.INFO)
sentry_sdk.init(   
    dsn="YOUR_SENTRY_URL",
    integrations=[sentry_logging]
) 
Grimmer Kang
  • 235
  • 3
  • 10