如何捕获远程芹菜工人的标准输出? [英] How to capture stdout of remote celery worker?

查看:55
本文介绍了如何捕获远程芹菜工人的标准输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个远程Celery工作者的设置。在通过apply_async启动任务的主程序中,我需要连续访问活动远程工作者的标准输出。

I have a setup with multiple remote Celery workers. In the main program which is starting tasks via apply_async I need continuous access to stdout of active remote workers.

是否可以仅使用Celery API?

Is it possible using only Celery API?

推荐答案

我认为您应该设置 SysLogHandler CELERY_REDIRECT_STDOUTS CELERY_REDIRECT_STDOUTS_LEVEL 默认情况下适用于当前记录器。

I think you should set up your SysLogHandler. CELERY_REDIRECT_STDOUTS and CELERY_REDIRECT_STDOUTS_LEVEL are working by default with current logger.

您可以尝试这样的示例(在远程服务器上):

You can try example so (on remote servert):


import logging
from logging.handlers import SysLogHandler

logger = logging.getLogger()
logger.setLevel(logging.INFO)
# host is your server that used for the log
syslog = SysLogHandler(address=(host, port))
formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s')
syslog.setFormatter(formatter)
logger.addHandler(syslog)

# check it
logger.info("Test test")


这篇关于如何捕获远程芹菜工人的标准输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆