I have a problem related with sending log messages to Sentry server while using Django and Celery async tasks. I utilize Django 1.11, Raven 6.1, Celery 4.0.2.
The log message shows in Sentry server when task is launching synchronous, for example:
@celery.shared_task()
def test_worker():
logger.warning('Logger works!')
raise Exception('---Worker works!')
$ from api.tasks import test_worker
$ test_worker()
When trying launch async task using: $ res = test_worker.delay() Sentry server does not contain log about logger.
My settings.py is:
RAVEN_CONFIG = {
'dsn': 'http://my_dsn',
}
SENTRY_AUTO_LOG_STACKS = True
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'root': {
'level': 'DEBUG',
'handlers': ['sentry'],
},
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s - %(message)s'
},
'verbose': {
'format': '%(asctime)s [%(levelname)s] %(module)s:%(funcName)s - %(message)s'
},
},
'handlers': {
# logs directly to Sentry
'sentry': {
'level': 'DEBUG',
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
},
# logs everything to the console
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'raven': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
'sentry.errors': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
'processing': {
'level': 'DEBUG',
'handlers': ['sentry'],
'propagate': False
},
'celery': {
'level': 'DEBUG',
'handlers': ['sentry'],
'propagate': False
}
},
}
Where I made a mistake, or what I am doing wrong?
Thanks in advance.