title: Logging to different places based on various functions
body: <p>As a test, I wrote the following python code:</p>
  
  <pre><code>import logging
  
  def hello():
      logging.basicConfig(filename='hello.log', level=logging.DEBUG)
      logging.info('Hello 1')
  
  
  def goodbye():
      logging.basicConfig(filename='goodbye.log', level=logging.DEBUG)
      logging.info('Goodbye 1')
  
  
  if __name__ == '__main__':
      logging.basicConfig(filename='main.log', level=logging.DEBUG)
      logging.info('Main 1')
      hello()
      goodbye()
      logging.info('Main 2')
  </code></pre>
  
  <p>However, instead of logging to the three different files (hello, goodbye, and main), it logged all four statements to the <code>main.log</code> file. Why is this so? What would be the correct way to route each of the logs to a different file base on its function.</p>