I'm using Celery 3.1.18 with Python 2.7.8 on CentOS 6.5.
In a Celery task module, I have the following code:
# 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"测试中")
I use the initd script here to run a Celery worker. Also I put the following settings in /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"
So my log file is located in /var/log/celery/bar.log
.
However, once the task is executed by the worker, the above log file shows:
[2015-05-07 03:51:14,438: INFO/Worker-1/someapp.tasks.foo(...)] Test output: ???
The unicode characters are gone, replaced with a number of question marks.
How can I get back the unicode characters in the log file?