title: UWSGI does not redirect application stdout to stdout, only to file
body: <p>I have a Flask application running inside a container, where I have setup the logging with the <code>StreamHandler()</code>, so the logs are sent to stdout.<br>
  When my <code>uwsgi.ini</code> file includes a statement to redirect the logs to a file (by using <code>logto</code>), then the logs from the application are available in the log file intermixed with the uWSGI logs (as it is expected).</p>
  
  <p>But when I remove the <code>logto</code> from the <code>uwsgi.ini</code> - because I want those logs sent to the Docker container stdout only the uWSGI logs are visible in the docker container logs, the application logs are not. (the uWSGI logs were there even before)</p>
  
  <p>uwsgi.ini:</p>
  
  <pre><code>[uwsgi]
  base = /app_home/app
  wsgi-file = /app_home/app/wsgi.py
  callable = app
  socket = /tmp/uwsgi.sock
  chmod-socket    = 666
  # Log directory - we needed this to be turned off, so the logs are sent to STDOUT
  # logto = /var/log/uwsgi/app.log
  vacuum = true
  master = true
  processes = 3
  enable-threads = true
  uid = app
  gid = app
  master-fifo = /tmp/fifo0
  master-fifo = /tmp/fifo1
  
  chdir = /app_home/app
  </code></pre>
  
  <p>When the <code>logto</code> is enabled, then the log file includes the app's logs (as it should):</p>
  
  <pre><code>[2019-03-05 17:19:05,415] INFO in __init__: Initial starting of app...
  2019-03-05 17:19:05,415 (9) - INFO - Initial starting of app...- [in ./app/__init__.py:128, function:create_app]
  WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x1ad49b0 pid: 9 (default app)
  *** uWSGI is running in multiple interpreter mode ***
  gracefully (RE)spawned uWSGI master process (pid: 9)
  spawned uWSGI worker 1 (pid: 32, cores: 1)
  </code></pre>
  
  <p>Once the <code>logto</code> is disabled, then no log file (as expected), but no app logs in the Docker container log either. The docker container looks exactly the same as before:</p>
  
  <pre><code>2019-03-05T22:19:09.956784133Z 2019-03-05 17:19:09,956 CRIT Supervisor running as root (no user in config file)
  2019-03-05T22:19:09.959701644Z 2019-03-05 17:19:09,959 INFO supervisord started with pid 1
  2019-03-05T22:19:10.961366502Z 2019-03-05 17:19:10,961 INFO spawned: 'nginx' with pid 9
  2019-03-05T22:19:10.963312945Z 2019-03-05 17:19:10,962 INFO spawned: 'uwsgi' with pid 10
  2019-03-05T22:19:12.928470278Z 2019-03-05 17:19:12,928 INFO success: nginx entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs)
  2019-03-05T22:19:12.928498809Z 2019-03-05 17:19:12,928 INFO success: uwsgi entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs)
  </code></pre>
  
  <p>uWSGI documentation shows that the logs are sent to stdout/stderr by default (see <a href="https://uwsgi-docs.readthedocs.io/en/latest/Logging.html" rel="noreferrer">https://uwsgi-docs.readthedocs.io/en/latest/Logging.html</a>), so I don't really see a reason why the app's logs would be not sent to stdout with the uWSGI's own logs, but sent to a file with <code>logto</code>.</p>
  
  <p><strong>EDIT (SOLVED)</strong>:<br>
  So it turns out there were two issues:</p>
  
  <ol>
  <li>As uWSGI is running in the Docker container with Supervisor, I need to make supervisor to redirect the stdout of uwsgi to its stdout.<br>
  supervisord.conf:</li>
  </ol>
  
  <blockquote>
  <pre><code>[program:uwsgi]
  command=/usr/local/bin/uwsgi --ini /app_home/app/uwsgi.ini --uid app --gid app --log-master
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  </code></pre>
  </blockquote>
  
  <p>While this has worked with other applications (like NGinx), it was not enough for uWSGI, see step #2:</p>
  
  <ol start="2">
  <li>A special flag (<code>--log-master</code>) had to be added to uWSGI to delegate the logging to the master process:</li>
  </ol>
  
  <blockquote>
  <pre><code>[program:uwsgi]
  command=/usr/local/bin/uwsgi --ini /app_home/app/uwsgi.ini --uid app --gid app --log-master
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  </code></pre>
  </blockquote>
  
  <p>And whoala, the logs from the Flask applications are visible in the Docker container log.</p>