【发布时间】:2016-05-17 17:59:58
【问题描述】:
当我遇到错误时,我想登录 Django 和 Gunicorn。 我用 Python 学习 TDD,http://chimera.labs.oreilly.com/books/1234000000754/ch17.html#_setting_up_logging
这是我的代码。 /etc/init/gunicorn-superlists-staging.mysite.com.conf
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
accounts/authentication.py
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
超级列表/settings.py
[....]
LOGGING = {
'version': 1,
'disable_existing_logger': False,
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
},
},
'root': {'level': 'INFO'},
}
我的“error.log”只是记录这个。
[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
我想查看错误日志,我该怎么办?
【问题讨论】: