Error message 'No handlers could be found for logger “multiprocessing”' using Celery

泄露秘密 提交于 2019-12-13 15:03:49

问题


RabbitMQ now seems to be working correctly. However, when I try

python -m celery.bin.celeryd --loglevel=INFO` 

(regular celeryd doesn't work), I get the error

No handlers could be found for logger "multiprocessing"`).

Here's the full output (redacted slightly):

[2011-06-06 02:08:08,105: WARNING/MainProcess] -------------- celery@blahblah v2.2.6
---- **** -----
--- * ***  * -- [Configuration]
-- * - **** ---   . broker:      amqplib://blah@localhost:5672/vhost
- ** ----------   . loader:      celery.loaders.default.Loader
- ** ----------   . logfile:     [stderr]@INFO
- ** ----------   . concurrency: 2
- ** ----------   . events:      OFF
- *** --- * ---   . beat:        OFF
-- ******* ----
--- ***** ----- [Queues]
 --------------   . celery:      exchange:celery (direct) binding:celery


[Tasks]
  . tasks.add
[2011-06-06 02:08:08,812: WARNING/MainProcess] celery@blahblah has started
.
No handlers could be found for logger "multiprocessing"
No handlers could be found for logger "multiprocessing"

I'd really like to get this set up properly, so I can move on to using it with Django!

(It is not my first no handlers found error, but I'm having trouble finding anything on the web regarding this...)


回答1:


There seems to be something strange in the way celery initializes logging. If I put the switch --logfile=yourfile.log on the command-line, it works reliably, but reading the logging from the config gives unreliable results including the stuff you're seeing.




回答2:


You need to ensure that all processes started from the main process also set up logging correctly. Here's a post which discusses how best to do logging with multiprocessing. Though that discusses features with came in with Python 3.2, you can also get this functionality for earlier Python versions - see this other post.

Update: The point is that each process needs to initialise logging, and you need to arrange this in your code, in a similar way to what is done in the example in the first post: see listener_configurer and worker_configurer. You can use logutils to help you, but the main thing is to realise that each process needs to configure logging, if you are to avoid that "no handlers could be found" message.




回答3:


Make sure the log file directory exists the and processes has write permission to the log directory.

I faced similar issue , after creating log file location directory the problem went away.



来源:https://stackoverflow.com/questions/6244554/error-message-no-handlers-could-be-found-for-logger-multiprocessing-using-ce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!