title: Error Logging in Django and Gunicorn
body: <p>I want logging in Django and Gunicorn, when I get error.
  I study with TDD with Python, <a href="http://chimera.labs.oreilly.com/books/1234000000754/ch17.html#_setting_up_logging" rel="noreferrer">http://chimera.labs.oreilly.com/books/1234000000754/ch17.html#_setting_up_logging</a></p>
  
  <p>this is my code.
  /etc/init/gunicorn-superlists-staging.mysite.com.conf</p>
  
  <pre><code>description "Gunicorn server for superlists-staging.mysite.com"
  
  start on net-device-up
  stop on shutdown
  
  respawn
  
  setuid junsu
  chdir /home/junsu/sites/superlists-staging.mysite.com/source
  
  exec ../virtualenv/bin/gunicorn \
      --bind unix:/tmp/superlists-staging.mysite.com.socket \
      --access-logfile ../access.log \
      --error-logfile ../error.log \
      superlists.wsgi:application
  </code></pre>
  
  <p>accounts/authentication.py</p>
  
  <pre><code>import requests
  import logging
  from django.contrib.auth import get_user_model
  User = get_user_model()
  
  PERSONA_VERIFY_URL = 'https://verifier.login.persona.org/verify'
  DOMAIN = 'localhost'
  
  class PersonaAuthenticationBackend(object):
  
      def authenticate(self, assertion):
          logging.warning('authenticate function')
          response = requests.post(
              PERSONA_VERIFY_URL,
              data={'assertion': assertion, 'audience': settings.DOMAIN}
          )
          logging.warning('got response form persona')
          logging.warning(response.content.decode())
          if response.ok and response.json()['status'] == 'okay':
              email = response.json()['email']
              try:
                  return User.objects.get(email=email)
              except User.DoesNotExist:
                  return User.objects.create(email=email)
  
      def get_user(self, email):
          try:
              return User.objects.get(email=email)
          except User.DoesNotExist:
              return None
  </code></pre>
  
  <p>superlists/settings.py</p>
  
  <pre><code>[....]
  LOGGING = {
      'version': 1,
      'disable_existing_logger': False,
      'handlers': {
          'console': {
              'level': 'DEBUG',
              'class': 'logging.StreamHandler',
          },
      },
      'loggers': {
          'django': {
              'handlers': ['console'],
          },
      },
      'root': {'level': 'INFO'},
  }
  </code></pre>
  
  <p>my "error.log" just log this.</p>
  
  <pre><code>[2016-02-08 14:42:56 +0900] [3355] [INFO] Listening at: unix:/tmp/superlists-staging.mysite.com.socket (3355)
  [2016-02-08 14:42:56 +0900] [3355] [INFO] Using worker: sync
  [2016-02-08 14:42:56 +0900] [3359] [INFO] Booting worker with pid: 3359
  [2016-02-08 14:58:22 +0900] [3355] [INFO] Handling signal: term
  [2016-02-08 14:58:22 +0900] [3355] [INFO] Shutting down: Master
  [2016-02-08 14:58:22 +0900] [3470] [INFO] Starting gunicorn 19.4.3
  [2016-02-08 14:58:22 +0900] [3470] [INFO] Listening at: unix:/tmp/superlists-staging.mysite.com.socket (3470)
  [2016-02-08 14:58:22 +0900] [3470] [INFO] Using worker: sync
  [2016-02-08 14:58:22 +0900] [3474] [INFO] Booting worker with pid: 3474
  </code></pre>
  
  <p>I want see error loging, What can I do?</p>