title: Logging with WSGI server and flask application
body: <p>I am using wsgi server to spawn the servers for my web application. I am having problem with information logging. </p>
  
  <p>This is how I am running the app</p>
  
  <pre><code>from gevent import monkey; monkey.patch_all()
  from logging.handlers import RotatingFileHandler
  import logging
  from app import app # this imports app
  
  # create a file to store weblogs
  log = open(ERROR_LOG_FILE, 'w'); log.seek(0); log.truncate();
  log.write("Web Application Log\n"); log.close();
  
  log_handler = RotatingFileHandler(ERROR_LOG_FILE, maxBytes =1000000, backupCount=1)
  
  formatter = logging.Formatter(
      "[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s"
      )
  log_handler.setFormatter(formatter)
  app.logger.setLevel(logging.DEBUG)
  app.logger.addHandler(log_handler)
  
  # run the application
  server=  wsgi.WSGIServer(('0.0.0.0', 8080), app)
  server.serve_forever()
  </code></pre>
  
  <p>However, on running the application it is not logging anything. I guess it must be because of WSGI server because app.logger works in the absence of WSGI. How can I log information when using WSGI?</p>