title: How to debug/log wsgi python app?
body: <p>I tried this:</p>
  
  <pre><code>#!/usr/bin/python    
  
  from wsgiref.simple_server import make_server
  from cgi import parse_qs, escape
  import logging
  import os
  import sys
  
  html = """
  &lt;html&gt;
  &lt;body&gt;
     &lt;form method="post" action="parsing_post.wsgi"&gt;
        &lt;p&gt;
           Age: &lt;input type="text" name="age"&gt;
           &lt;/p&gt;
        &lt;p&gt;
           Hobbies:
           &lt;input name="hobbies" type="checkbox" value="software"&gt; Software
           &lt;input name="hobbies" type="checkbox" value="tunning"&gt; Auto Tunning
           &lt;/p&gt;
        &lt;p&gt;
           &lt;input type="submit" value="Submit"&gt;
           &lt;/p&gt;
        &lt;/form&gt;
     &lt;p&gt;
        Age: %s&lt;br&gt;
        Hobbies: %s
        &lt;/p&gt;
     &lt;/body&gt;
  &lt;/html&gt;
  """
  
  def application(environ, start_response):
  
     # the environment variable CONTENT_LENGTH may be empty or missing
     try:
        request_body_size = int(environ.get('CONTENT_LENGTH', 0))
     except (ValueError):
        request_body_size = 0
  
     # When the method is POST the query string will be sent
     # in the HTTP request body which is passed by the WSGI server
     # in the file like wsgi.input environment variable.
     logger = logging.getLogger(__name__)
     request_body = environ['wsgi.input'].read(request_body_size)
     d = parse_qs(request_body)
  
  
     age = d.get('age', [''])[0] # Returns the first age value.
     hobbies = d.get('hobbies', []) # Returns a list of hobbies.
  
     # Always escape user input to avoid script injection
     age = escape(age)
     hobbies = [escape(hobby) for hobby in hobbies]
  
     response_body = html % (age or 'Empty',
                 ', '.join(hobbies or ['No Hobbies']))
  
     status = '200 OK'
  
     response_headers = [('Content-Type', 'text/html'),
                    ('Content-Length', str(len(response_body)))]
     start_response(status, response_headers)
  
     return [response_body]
  </code></pre>
  
  <p>But i don't know where it logs. I'm trying to display/log the value on webpage or in a file /var/log/apache2/myapp.log</p>
  
  <p>What's the best way to do this?</p>
  
  <p>Any answer will be highly appreciated.</p>