title: How to debug: uWSGI Error Python application not found. And how to set up uwsgi logging
body: <p>I'm running <code>nginx</code>, <code>uwsgi</code> and <code>pyramid</code>.</p>
  
  <p>I know that the error is due to something in my <code>production.ini</code> file but I'm not entirely sure what. I'm not so keen to guess what the problem is, I would much rather have a meaningful error message. </p>
  
  <ul>
  <li>/var/log/uwsgi/app/my_app_log is filled with info about how many bytes were sent when. </li>
  <li>/var/log/nginx/access.log is empty</li>
  <li>/var/log/nginx/error.log is empty</li>
  </ul>
  
  <p>Now apparently I can configure uwsgi to log things in an actually friendly way. I know there are logging options, I just don't know how to use them. Google isn't helping me out on this one.</p>
  
  <p>So my question is:</p>
  
  <p>How would I get <code>uwsgi</code> to log errors produced by errors in my <code>pyramid</code> app's <code>production.ini</code> file?</p>
  
  <p>/etc/uwsgi/apps-available/mega_capture.co.za.xml looks like:</p>
  
  <pre><code>&lt;uwsgi&gt;
      &lt;plugin&gt;python3&lt;/plugin&gt;
      &lt;socket&gt;/run/uwsgi/app/mega_capture.co.za/mega_capture.co.za.socket&lt;/socket&gt;
      &lt;pythonpath&gt;/srv/www/mega_capture.co.za/application/&lt;/pythonpath&gt;
      &lt;virtualenv&gt;/srv/www/mega_capture.co.za/application/venv/&lt;/virtualenv&gt;
      &lt;app mountpoint="/"&gt;
          &lt;script&gt;wsgi_configuration_module&lt;/script&gt;
      &lt;/app&gt;
      &lt;master/&gt;
      &lt;processes&gt;4&lt;/processes&gt;
      &lt;harakiri&gt;60&lt;/harakiri&gt;
      &lt;reload-mercy&gt;8&lt;/reload-mercy&gt;
      &lt;cpu-affinity&gt;1&lt;/cpu-affinity&gt;
      &lt;stats&gt;/tmp/stats.socket&lt;/stats&gt;
      &lt;max-requests&gt;2000&lt;/max-requests&gt;
      &lt;limit-as&gt;512&lt;/limit-as&gt;
      &lt;reload-on-as&gt;256&lt;/reload-on-as&gt;
      &lt;reload-on-rss&gt;192&lt;/reload-on-rss&gt;
      &lt;no-orphans/&gt;
      &lt;vacuum/&gt;
  &lt;/uwsgi&gt;
  </code></pre>
  
  <p>/srv/www/mega_capture.co.za/application/wsgi_configuration_module.py looks like:</p>
  
  <pre><code>import os
  import sys
  
  sys.path.append('/srv/www/mega_capture.co.za/application')
  os.environ['PYTHON_EGG_CACHE'] = '/srv/www/mega_capture.co.za/.python-egg'
  
  from pyramid.paster import get_app, setup_logging
  ini_path = '/srv/www/mega_capture.co.za/application/venv/pyramidapp/production.ini'
  
  setup_logging(ini_path)
  application = get_app(ini_path, 'main')
  </code></pre>