Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery Logs into file

Tags:

python

celery

Can someone please help and tell me how to get the celery task debug details to a log file? I have a requirement to have the details of celery task logged into a .log file.

Can you please make some suggestions on how this can be done without impacting the performance of the task?

like image 826
user2479840 Avatar asked Jun 28 '13 14:06

user2479840


People also ask

Where are Celery logs stored?

Default is /var/run/celery/%n. pid. CELERYD_LOG_FILE — Full path to the worker log file.

How to log Celery task in Django?

Generally for configuring Celery you will have created a file in your main Django app in which your settings.py file is present. Add a config_loggers function in that file so that it is now able to use your configured settings for logging instead of its own.

How do I check the status of my Celery worker?

celery -A yourproject. app inspect status will give the status of your workers. celery -A yourproject. app inspect active will give you list of tasks currently running, etc.


2 Answers

It's alway hard to answer with so little information in question, but I'll try. Celery have specific option -f --logfile which you can use:

-f LOGFILE, --logfile=LOGFILE                     Path to log file. If no logfile is specified, stderr                     is used. 

To get information about other options, just use celery worker --help. If just want want celery worker with logging to file, your command may look like this:

celery worker -f <filename> python manage.py celery worker -f <filename> -> in django-celery case 

There are a lot of logging options for Celery you may need: http://docs.celeryproject.org/en/latest/userguide/tasks.html#logging

like image 123
Artem Mezhenin Avatar answered Sep 23 '22 23:09

Artem Mezhenin


If you want to log everything, you can use the following command

-f celery.logs

You can also specify different log levels as well. For suppose if you want log warning and errors add like following.

--loglevel=warning -f celery.logs

like image 36
Raja Avatar answered Sep 21 '22 23:09

Raja