title: Why isn't my Python logging setup working?
body: <p>My code looks like this</p>
  <pre class="lang-py prettyprint-override"><code>import logging
  
  formatter = logging.Formatter(&quot;{asctime} - {name} - {levelname} - {message}&quot;,
                                &quot;%d-%b-%y %H:%M&quot;, &quot;{&quot;)
  
  
  def _add_handler(handler: logging.StreamHandler) -&gt; logging.StreamHandler:
      handler.setFormatter(formatter)
      handler.setLevel(20)
      return handler
  
  logging.basicConfig(
      handlers={
          _add_handler(logging.FileHandler(&quot;filename.log&quot;)),
          _add_handler(logging.StreamHandler())
      })
  logging.info(&quot;hello world&quot;)
  </code></pre>
  <p>What this is <em>supposed</em> to do is log <code>&quot;hello world&quot;</code> both to the console and a file named <code>filename.log</code>, with a severity of <code>INFO</code>, which is what the <code>20</code> in the <code>setLevel</code> method is for. However, nothing is being logged at all. Where have I gone wrong?</p>