title: Python error log location
body: <p>I am developing a python application on <code>flask</code> framework. And I use <code>.wsgi</code> to deploy it. I got confused by error log locations. It looks like Python errors and debug information are put into different log files.</p>
  
  <p>First of all, I specify both access and error log locations in the <code>apache</code> <code>vhost</code> file.</p>
  
  <pre><code>&lt;VirtualHost *:myport&gt;
      ...
      CustomLog /homedir/access.log common
      ErrorLog /homedir/error.log
      ...
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>I also know there is another <code>apache</code> error log, <code>/var/log/httpd/error_log</code>. My access logs were printed into the right place, <code>/homedir/access.log</code>. </p>
  
  <p>But, error log looks weird. The Python errors, like <code>SyntaxError</code>, uncaught exceptions went to the log file specified in <code>vhost</code> file (<code>/homedir/error.log</code>). But, any log messages generated by python <code>logging</code> module, went to the "default" error log (<code>/var/log/httpd/error_log</code>).</p>
  
  <p>Can anyone explain why this is happening and how to fix it? I want these two logs go to the same place. </p>
  
  <hr>
  
  <p>Thanks for the comments. Here is the code I set up logger</p>
  
  <pre><code>import logging
  
  # I didn't specify the stream, so it suppose to be stderr
  # Don't know why stderr points to apache /var/log/*, rather than my error log
  
  stream_handler = logging.StreamHandler()
  formatter = logging.Formatter("%(levelname)s : %(pathname)s:%(lineno)s - %(msg)s")
  stream_handler.setFormatter(formatter)
  
  logger = logging.getLogger('foo')
  logger.addHandler(stream_handler)
  logger.setLevel(logging.DEBUG)
  </code></pre>
  
  <p>Then, I logged messages in this way.</p>
  
  <pre><code>import logging
  logger = logging.getLogger('foo.bar')
  
  logger.debug('Some debug information')
  </code></pre>
  
  <p>But, the log goes to /var/log/httpd/error_log, rather than the log specified in apache vhost file.</p>