title: Should I add encoding='utf-8' to my Python logging handler?
body: <p>
  Suppose I'd like to handle Unicode strings when logging using Python 2.7. It seems "right" to add the encoding parameter to the FileHandler.</p>
  
  <pre class="lang-py prettyprint-override"><code># coding=utf-8
  import logging
  
  logger = logging.getLogger()
  logger.addHandler(logging.FileHandler('my_log.txt', encoding='utf-8'))
  
  logger.error(u'Pão')
  logger.error('São')
  </code></pre>
  
  <p>This has a couple of problems, though:</p>
  
  <ol>
  <li>It raises a UnicodeDecodeError on the UTF-8 string literal 'São'.</li>
  <li>The output file has LF line endings on Windows, when CRLF seems more appropriate.</li>
  </ol>
  
  <p>If I don't pass any encoding at all, however, I have neither of those problems. Both strings are logged to a UTF-8 file and I get CRLF line endings. (I think the line ending issue has to do with the file opening in binary mode when an encoding is specified.)</p>
  
  <p>Since omitting the encoding seems to work better, is there some reason I'm missing that I would <em>ever</em> pass in <code>encoding='utf-8'</code>?</p>