Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Celery logging via Django into Sentry #4565

Closed
Duologic opened this issue Nov 18, 2016 · 3 comments
Closed

Getting Celery logging via Django into Sentry #4565

Duologic opened this issue Nov 18, 2016 · 3 comments

Comments

@Duologic
Copy link

Recently we updated Celery to 4.0 in our Django project. The logging gave us some headaches and I would like to help fellow hackers so they don't get stuck on this.

The issue is described in the Celery issue tracker but disregarded as they don't have enough resources to work on it: celery/celery#2437

We had to implement 2 things:

Set CELERYD_HIJACK_ROOT_LOGGER to False in our settings.

And connect to the setup_logging signal from Celery:

from celery import signals

@signals.setup_logging.connect
def setup_logging(**kwargs):
    """Setup logging."""     
    pass

It would be nice to see this reflected in the documentation somewhere. As it looks to me this is very Django-specific, I'd propose to putting it here: https://docs.sentry.io/clients/python/integrations/django/

I also got confused from the settings described on the page about Celery in the Sentry docs. The code there doesn't seem to be required for us. Not sure if we can change something about this to make it more clear when you should use that. Only when you are running celery<4.0 maybe? https://docs.sentry.io/clients/python/integrations/celery/

Otherwise, the docs are great, thank you for that!

What do you guys think?

@jmartinm
Copy link

By the way, the solution proposed by @Duologic works for us as well, but then in the developer machine when running celery like:

celery worker --loglevel=INFO

No output is generated so it is not nice for debugging/working with Celery.

Some way to have both working?

@Duologic
Copy link
Author

You can add an entry to the Django LOGGING dict to output any logging to the shell, I think.

@JTCunning
Copy link
Contributor

Hey you two,

Thanks for the information, but I'm guessing that these steps are suggested for raven-python and not Sentry the server.

It would be greatly appreciated if you could reopen the issue in that repository, and I can take it from there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants