title: Why Flask logger does not log in docker when using UWSGI in front?
body: <p>I have a <code>Flask</code> application inside of <code>Docker</code> that was logging into <code>docker logs</code> when it was running without <code>UWSGI</code> in front. Now I have used <code>UWSGI</code> with the config below to run my application inside of <code>Docker</code>:</p>
  
  <pre><code>[uwsgi]
  
  master = true
  
  processes = 5
  threads = 2
  
  socket = 127.0.0.1:3031
  chmod-socket = 664
  stats=0.0.0.0:30310
  
  chdir = /etc/fantas
  
  uid = root
  gid = root
  
  wsgi-file=uwsgi_fantas.py
  callable=app
  
  vacuum = true
  </code></pre>
  
  <p>The <code>uwsgi_fantas.py</code> file contains:</p>
  
  <pre><code>from fantas.fantas_app import FantasApp
  
  app = FantasApp().setup()
  </code></pre>
  
  <p>The <code>setup</code> method returns <code>app</code>:</p>
  
  <pre><code>from flask_restful import Api
  from fantas import app
  
  class FantasApp(object):
      def setup(self):
          api = Api(app)
          api.add_resource(Token, '/users')
  
          return app
  </code></pre>
  
  <p>Finally the part that initiates the <code>Flask</code> framework is inside of <code>__init__.py</code> in the root directory of project:</p>
  
  <pre><code>from flask import Flask
  import logging
  
  app = Flask(__name__)
  
  s_handler = logging.StreamHandler()
  s_handler.setLevel(logging.DEBUG)
  app.logger.addHandler(s_handler)
  </code></pre>
  
  <p>As <code>UWSGI</code> works directly with the <code>app</code> object I have configured logger inside of <code>__init__.py</code>, but the problem is that it does not log anything into <code>Docker</code> when it is run, it just logs <code>UWSGI</code> requests.</p>
  
  <p>What is wrong in the process of app.logger configuration? </p>
  
  <p><strong>Problem has been solved, but now logs get duplicated!</strong></p>
  
  <hr>
  
  <p><strong>EDIT-1:</strong>
  I set <code>app.logger.setLevel(logging.DEBUG)</code> and it seems that <code>Flask</code> logs into <code>Docker</code> successfully. The weird part is that it logs 3 times! I removed all logger configs and handlers and just used:</p>
  
  <pre><code>app.logger.setLevel(logging.DEBUG)
  </code></pre>
  
  <p>But now it logs 2 times:</p>
  
  <pre><code>proj_fantas.1.huagnqqpzo1n@linuxkit-025000000001    | [2018-07-13 07:02:38,008] DEBUG in token: [Token] authenticating user...
  proj_fantas.1.huagnqqpzo1n@linuxkit-025000000001    | DEBUG:flask.app:[Token] authenticating user...
  </code></pre>
  
  <p>Why it is like that?</p>
  
  <hr>
  
  <p><strong>EDIT-2:</strong></p>
  
  <p>The output of <code>app.logger.handlers</code> is <code>[&lt;logging.StreamHandler object at 0x7f0f430ca8d0&gt;]</code>. It just shows the StreamHandler that I initialized earlier, nothing more.</p>
  
  <hr>
  
  <p><strong>EDIT-3:</strong></p>
  
  <p>The output of <code>ps -ef</code> command inside of <code>Docker</code>:</p>
  
  <pre><code>UID        PID  PPID  C STIME TTY          TIME CMD
  root         1     0  0 15:26 ?        00:00:00 uwsgi uwsgi_coconuty.ini
  root        10     1  0 15:26 ?        00:00:00 uwsgi uwsgi_coconuty.ini
  root        12     1  0 15:26 ?        00:00:00 uwsgi uwsgi_coconuty.ini
  root        13     1  0 15:26 ?        00:00:00 uwsgi uwsgi_coconuty.ini
  root        15     1  0 15:26 ?        00:00:00 uwsgi uwsgi_coconuty.ini
  root        16     1  0 15:26 ?        00:00:00 uwsgi uwsgi_coconuty.ini
  root        20     0  0 15:27 pts/0    00:00:00 /bin/bash
  root       112    20  0 15:28 pts/0    00:00:00 ps -ef
  </code></pre>
  
  <p>There is no other process running inside of <code>Docker</code>.</p>