How to force application's stdout logs through

2019-06-17 02:06发布

问题:

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.

So far, so good.

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.

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```

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

Is there some more elegant solution?

Updated 2016-02-24:

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

回答1:

use

log-master=true

in your uwsgi-conf.ini or

--log-master

if you pass it as param