如何通过uwsgi强制应用程序的标准输出日志? [英] How to force application's stdout logs through uwsgi?

查看:100
本文介绍了如何通过uwsgi强制应用程序的标准输出日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Docker容器内的uwsgi后面运行了Django应用程序. uwsgi通过Dockerfile中的ENTRYPOINTCMD参数启动.我成功地将其连接到单独的Nginx容器,并在浏览器中检查了预期的结果.

I have Django application running behind uwsgi inside Docker container. uwsgi is started via ENTRYPOINT and CMD parameters in Dockerfile. I succesfully connect it to separated Nginx container and check expected results in browser.

到目前为止,很好.

现在,我想在Django容器中查看应用程序日志.但是我找不到Django设置LOGGING变量和uwsgi开关的正确组合.我只看到uwsgi标准日志,对我来说没用.

Now I would like see application logs in Django container. But I am not able to find right combination of Django's settings LOGGING variable and uwsgi switches. I just see uwsgi standard logs which is useless for me.

有可能吗?在我看来,我必须制作一些包装BASH脚本,例如:

Is it possible at all? It seems to me, that I must make some wrapper BASH script, like:

uwsgi --socket 0.0.0.0:80 --die-on-term --module myapp.wsgi:application --chdir /src --daemonize /dev/null
tail -f /common.log```

...在Django内部设置LOGGING以写入/common.log并将其尾部输出.

... set LOGGING inside Django to write into /common.log and tail it to output.

还有一些更优雅的解决方案吗?

Is there some more elegant solution?

更新了2016-02-24:

是的,有可能.我在第一次测试中的某个地方犯了错误.我在 https://github.com/msgre/uwsgi_logging 上发布了工作示例.

Yes, it is possible. I made mistake somewhere in my first tests. I published working example on https://github.com/msgre/uwsgi_logging.

推荐答案

使用

log-master = true

log-master=true

在您的uwsgi-conf.ini中 或

in your uwsgi-conf.ini or

-log-master

--log-master

如果将其作为参数传递

这篇关于如何通过uwsgi强制应用程序的标准输出日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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