简体   繁体   English

芹菜登录文件

[英]Celery Logs into file

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. 我要求将celery任务的详细信息记录到.log文件中。

Can you please make some suggestions on how this can be done without impacting the performance of the task? 在没有影响任务执行情况的情况下,您能否就如何做到这一点提出一些建议?

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: Celery有特定的选项-f --logfile ,您可以使用:

-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 . 要获得有关其他选项的信息,请使用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 您可能需要Celery有很多日志记录选项: http//docs.celeryproject.org/en/latest/userguide/tasks.html#logging

If you want to log everything, you can use the following command 如果要记录所有内容,可以使用以下命令

-f celery.logs -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 --loglevel = warning -f celery.logs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM