title: Python logging FileHandler outputting blank file
body: <p>I'm trying to change all my overused prints, to logging.* mainly because i wanted to have a logfile.</p>
  <pre><code>logger = logging.getLogger(__name__)
  formatter = logging.Formatter(&quot;{levelname}:{name}:{message}&quot;, style=&quot;{&quot;)
  
  file_handler = logging.FileHandler(&quot;log.txt&quot;)
  file_handler.setFormatter(formatter)
  file_handler.setLevel(logging.DEBUG)
  logger.addHandler(file_handler)
  
  console_handler = logging.StreamHandler()
  console_handler.setLevel(logging.INFO)
  console_handler.setFormatter(formatter)
  logger.addHandler(console_handler)
  
  logger.setLevel(logging.DEBUG)
  </code></pre>
  <p>Thats the code i have for now, and it's printing to the console correctly but not outputting anything at all to the file. The file even gets created randomly, but but when it does, it's always empty.</p>
  <p>I'm using <code>logger.debug()</code> and <code>logger.info()</code>, not the <code>logging.*</code> ones.</p>
  <h3>Update:</h3>
  <p>Just copying that same code to an empty script, and importing works as expected. Weird.</p>
  <h3>Update 2:</h3>
  <p>I found <a href="https://stackoverflow.com/questions/7881411/solved-python-logging-get-loggername-with-filehandler-does-not-write-to-file">a question</a> that has the same problem as me, he says he found a solution, but he doesn't share it :(</p>
  <h3>Update 3:</h3>
  <p>This is my <a href="http://pastebin.com/JwGBh62G" rel="nofollow noreferrer">source</a>. The code gets called by uTorrent everytime the status of a torrent changes. This is the command i have setup in uTorrent:</p>
  <pre><code>py C:\Users\Gcq\Downloads\Torrent\torrent.py -n %N -d %D -f %F -p %P -c %S -s %M
  </code></pre>
  <p>py because i have  shebang at the top of my script that tells py to use python3. I have python2.7 installed too.<br />
  And the the commandline otions are the info that uTorrent exposes.</p>