title: python3 logger - UnicodeEncodeError
body: <p>I have a logger setup like this:</p>
  
  <pre><code>import logging
  from logging.handlers import RotatingFileHandler
  import sys
  
  # root logger
  logger = logging.getLogger(__name__)
  logger.setLevel(logging.INFO)
  
  # create a file logger
  handler = RotatingFileHandler('log/core-application.log', maxBytes=1024*1024*1, backupCount=3)
  handler.setLevel(logging.INFO)
  formatter = logging.Formatter('%(asctime)s - %(funcName)s - %(levelname)s - %(message)s')
  handler.setFormatter(formatter)
  logger.addHandler(handler)
  
  
  # create stdout logger
  handler = logging.StreamHandler(sys.stdout)
  handler.setLevel(logging.DEBUG)
  formatter = logging.Formatter('%(asctime)s - %(funcName)s - %(levelname)s - %(message)s')
  handler.setFormatter(formatter)
  logger.addHandler(handler)
  
  logger.info('Logging all setup')
  </code></pre>
  
  <p>On my development system this logging entry is working ok. It logs what you see here:</p>
  
  <p><code>logger.info('message key: {}'.format('2018-10-19_00:20:56_\xd8\xa7\xd9\x84\xd8\xb5\xd9\x88\xd8\xa7\xd9\x81/'))</code></p>
  
  <p>The same line on my ubuntu AWS EC2 server gives me an error:</p>
  
  <blockquote>
    <p>--- Logging error --- Traceback (most recent call last):   File "/usr/lib/python3.5/logging/<strong>init</strong>.py", line 982, in emit
        stream.write(msg) UnicodeEncodeError: 'ascii' codec can't encode characters in position 108-113: ordinal not in range(128)</p>
  </blockquote>
  
  <p>Can anybody image why this is?</p>
  
  <p>btw:
  EC2 server locales are: </p>
  
  <p><code>LC_ALL=en_US.UTF-8</code>
  <code>LANG=en_US.UTF-8</code></p>
  
  <p>Thanks in advance.</p>