如何通过uwsgi强制应用程序的标准输出日志? [英] How to force application's stdout logs through uwsgi?
问题描述
我在Docker容器内的uwsgi
后面运行了Django应用程序. uwsgi
通过Dockerfile中的ENTRYPOINT
和CMD
参数启动.我成功地将其连接到单独的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屋!