title: Python using basicConfig method to log to console and file
body: <p>I don't know why this code prints to the screen, but not to the file? File &quot;example1.log&quot; is created, but nothing is written there.</p>
  <pre><code>#!/usr/bin/env python3
  import logging
  
  logging.basicConfig(level=logging.DEBUG,
                      format='%(asctime)s %(message)s',
                      handlers=[logging.FileHandler(&quot;example1.log&quot;),
                                logging.StreamHandler()])
  logging.debug('This message should go to the log file and to the console')
  logging.info('So should this')
  logging.warning('And this, too')
  </code></pre>
  <p>I have &quot;bypassed&quot; this problem by creating a logging object, but it keeps bugging me why <code>basicConfig()</code> approach failed?</p>
  <p>PS. If I change basicConfig call to:</p>
  <pre><code>logging.basicConfig(level=logging.DEBUG,
                      filename=&quot;example2.log&quot;,
                      format='%(asctime)s %(message)s',
                      handlers=[logging.StreamHandler()])
  </code></pre>
  <p>then all logs are in the file and nothing is displayed in the console.</p>