From experience using
get_task_logger seems to get you a few things of importance, especially with Sentry.
- Auto prepending task names to your log output
- The ability to set log handling rules at a higher level than just module (I believe it’s actually setting the logger name to
- Probably, most importantly for Sentry setup, is it hooks the logging into their log handlers which Sentry makes use of.
Important: There is a bit of extra config that needs to go into Celery registration for Sentry:
You may be able to get errors to flow into Sentry without some of this setup, but I think this will give you the best traces and details + ensure that things like expected exceptions declared via
throws are properly ignored.