How to write for python login with nginx + uwsgi

I have a server running nginx + UWSGI + python. UWSGI works as a daemon with the flag set: --daemonize /var/log/uwsgi.log , which logs all application errors.

I noticed that on error, if I use the python print statement, it will write to the log, but only on error. The standard python logging library does not seem to affect the log in any situation.

How can I tell python log libraries to use UWSGI log?

+6
source share
2 answers

use logging.StreamHandler as a logging handler

+4
source

uWSGI is a wsgi server, and thus passes the stream to environ dict, passed to the application invoking its hosts using the wsgi.errors key. If you are writing an application with open wsgi, then writing to this stream should do the job. If you use a framework that abstracts the wsgi interface (and by its sound you, print , usually write to sys.stdout , which closes on a demonized process and never gets into any log file), you probably need to learn how this structure handles error logging.

+2
source

Source: https://habr.com/ru/post/900852/


All Articles