django-structlog: Celery Beat doesn't create any logs when using django-structlog

When using Celery, is common to also use Celery Beat to send periodic tasks to the Celery queue. A normal setup is to have 2 Django services, one running Celery and one running Celery Beat.

The service running Celery is logging everything properly:

2023-07-24T05:06:01.923895Z [info     ] task_started           [django_structlog.celery.receivers] 
2023-07-24T05:06:01.931920Z [info     ] email_reminder         [apps.email.tasks]  
2023-07-24T05:06:01.937263Z [info     ] task_succeeded         [django_structlog.celery.receivers]

But the service running Celery Beat doesn’t produce any logs (only shows the startup logs):

celery beat v5.3.0 (emerald-rush) is starting.
__    -    ... __   -        _
LocalTime -> 2023-07-23 22:09:42
Configuration ->
. broker -> sqs://localhost//
. loader -> celery.loaders.app.AppLoader
. scheduler -> django_celery_beat.schedulers.DatabaseScheduler

. logfile -> [stderr]@%INFO
. maxinterval -> 5.00 seconds (5s)

------------------

No more logs are created here :-(

Normally Celery Beat outputs a log line each time it creates a new task. Something like this:

2023-06-23 08:00:00,100 INFO beat: Scheduler: Sending due task email_reminder (email_reminder_task)

Would it be possible to add structured logs also the Celery Beat?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

Is "django_structlog", in your INSTALLED_APPS? Some of the events will not work if not there but I think it’s not your problem.

Thats django_structlog, not django_structlog.*

Thanks but still no logs coming through when adding this.

Is "django_structlog", in your INSTALLED_APPS? Some of the events will not work if not there but I think it’s not your problem.

You are a savior!! Yes! That was the issue! It’s weird that everything was working properly except that. Thanks!!!

Thats django_structlog, not django_structlog.*