title: logging error : TypeError: a bytes-like object is required, not 'str'
body: <p>when I updated the python from 2.7.16 to 3.7.4 on my project,the django console show logging error as follows:</p>
  
  <pre><code>--- Logging error ---
  Traceback (most recent call last):
    File "c:\python37\Lib\logging\__init__.py", line 1028, in emit
      stream.write(msg + self.terminator)
  TypeError: a bytes-like object is required, not 'str'
  </code></pre>
  
  <p>But It works fine when i used python2.7</p>
  
  <p>My Env:windows 10 python3.7.4 django2.2.5 eclipse+pydev7.3.0.201908161924
  the django settings.py about the logging part</p>
  
  <pre><code>log_path = config.get('log', 'log_path')  #windows path
  
  LOGGING = {
      'version': 1,
      'disable_existing_loggers': False,
      'filters': {
          'require_debug_true': {
              '()': 'django.utils.log.RequireDebugTrue',
          },
          'require_debug_false': {
              '()': 'django.utils.log.RequireDebugFalse',
          },
      },
      'formatters': {
          'standard': {
              'format': '%(asctime)s|%(levelname)s|%(process)d|%(funcName)s|%(lineno)d|msg:%(message)s'
          },
          'verbose': {
              'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
              'style': '{',
          },
          'simple': {
              'format': '{levelname} {message}',
              'style': '{',
          },
      },
      'handlers': {
          'mail_admins': {
              'level': 'ERROR',
              'class': 'django.utils.log.AdminEmailHandler',
              'filters': ['require_debug_false'],  #  DEBUG = False sendemail
              'include_html':True,
              'formatter': 'verbose',
          },
          'default': {
              'level': 'INFO',
              'class': 'logging.handlers.RotatingFileHandler',
              'filename': os.path.join(log_path,'skstack.log'),  
              'maxBytes': 1024 * 1024 * 5,  
              'backupCount': 5,  
              'formatter': 'verbose',  
          },
          'error_file': {
              'level': 'ERROR',
              'class': 'logging.handlers.RotatingFileHandler',
              'filename': os.path.join(log_path,'skstack-error.log'),
              'formatter': 'verbose'
          },
          'info_file': {
              'level': 'INFO',
              'class': 'logging.handlers.RotatingFileHandler',
              'filename': os.path.join(log_path,'skstack-info.log'),
              'formatter': 'verbose'
          },
          'debug': {
              'level': 'DEBUG',
              'class': 'logging.handlers.RotatingFileHandler',
              'filename': os.path.join(log_path,'skstack-debug.log'),
              'maxBytes': 1024 * 1024 * 5,  
              'backupCount': 5,  
              'formatter': 'verbose',  
          },
  
          'console': {
              'level': 'DEBUG',
              'filters': ['require_debug_false'],
              'class': 'logging.StreamHandler',
              'formatter': 'simple'
          },
           'skworkorders_log': {
              'level': 'INFO',
              'class': 'logging.handlers.RotatingFileHandler',
              'filename': os.path.join(log_path,'skworkorders.log'),
              'formatter': 'verbose'
          },
  
      },
      'loggers': {
          'django': {
              'handlers': ['console', 'info_file'],
              'propagate': True,
          },
          'django.request': {
              'handlers': ['console', 'info_file'],
              'level': 'ERROR',
              'propagate': False,
          },
          'skstack': {
              'handlers': ['console', 'info_file'],
              'level': 'DEBUG',
              'propagate': False,
          },
           'skworkorders': {
              'handlers': ['skworkorders_log','console'],
              'level': 'INFO',
              'propagate': False,
          },
      }
  }
  </code></pre>
  
  <p>the full error log</p>
  
  <pre><code>--- Logging error ---
  Traceback (most recent call last):
    File "c:\python37\Lib\logging\__init__.py", line 1028, in emit
      stream.write(msg + self.terminator)
  TypeError: a bytes-like object is required, not 'str'
  Call stack:
    File "c:\python37\Lib\threading.py", line 890, in _bootstrap
      self._bootstrap_inner()
    File "c:\python37\Lib\threading.py", line 926, in _bootstrap_inner
      self.run()
    File "c:\python37\Lib\threading.py", line 870, in run
      self._target(*self._args, **self._kwargs)
    File "c:\python37\Lib\socketserver.py", line 650, in process_request_thread
      self.finish_request(request, client_address)
    File "c:\python37\Lib\socketserver.py", line 360, in finish_request
      self.RequestHandlerClass(request, client_address, self)
    File "c:\python37\Lib\socketserver.py", line 720, in __init__
      self.handle()
    File "C:\virtualEnv\sk-stack\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
      self.handle_one_request()
    File "C:\virtualEnv\sk-stack\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
      handler.run(self.server.get_app())
    File "c:\python37\Lib\wsgiref\handlers.py", line 138, in run
      self.finish_response()
    File "c:\python37\Lib\wsgiref\handlers.py", line 196, in finish_response
      self.close()
    File "C:\virtualEnv\sk-stack\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
      super().close()
    File "c:\python37\Lib\wsgiref\simple_server.py", line 35, in close
      self.status.split(' ',1)[0], self.bytes_sent
    File "c:\python37\Lib\http\server.py", line 544, in log_request
      self.requestline, str(code), str(size))
    File "C:\virtualEnv\sk-stack\lib\site-packages\django\core\servers\basehttp.py", line 154, in log_message
      level(format, *args, extra=extra)
  Message: '"%s" %s %s'
  Arguments: ('GET /skworkorders/WorkOrderCommit/ HTTP/1.1', '200', '35764')
  </code></pre>
  
  <p>I can see that the django request log has been recorded in skstack-info.log</p>
  
  <pre><code>2019-09-19 11:44:40,515|INFO|60880|log_message|154|msg:"GET 
  /skworkorders/WorkOrderCommit/ HTTP/1.1" 200 35764
  </code></pre>
  
  <p>when i modify File "c:\python37\Lib\logging__init__.py", line 1029, in emit</p>
  
  <pre><code>stream.write(msg + self.terminator)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>stream.write(str.encode(msg + self.terminator))
  </code></pre>
  
  <p>it also show me the another error as following:</p>
  
  <pre><code>--- Logging error ---
  Traceback (most recent call last):
    File "c:\python37\Lib\logging\__init__.py", line 1029, in emit
      stream.write(str.encode(msg + self.terminator))
  TypeError: write() argument must be str, not bytes
  </code></pre>