我在CentOS 6.5上使用Celery 3.1.18和Python 2.7.8.
在Celery任务模块中,我有以下代码:
# someapp/tasks.py
from celery import shared_task
from celery.utils.log import get_task_logger
logger = get_task_logger(__name__)
@shared_task()
def foo():
logger.info('Test output: %s', u"???")
Run Code Online (Sandbox Code Playgroud)
我在这里使用initd脚本来运行Celery worker.我还将以下设置放入/etc/default/celeryd
:
CELERYD_NODES="bar"
# %N will be replaced with the first part of the nodename.
CELERYD_LOG_FILE="/var/log/celery/%N.log"
# Workers should run as an unprivileged user.
# You need to create this user manually (or you can choose
# a user/group combination that already exists, e.g. nobody).
CELERYD_USER="nobody"
CELERYD_GROUP="nobody"
Run Code Online (Sandbox Code Playgroud)
所以我的日志文件位于/var/log/celery/bar.log …