0
我在nginx/uWSGI上運行Django 1.8站點。如何獲取有關Django HTTP 500錯誤的信息
在./manage.py runserver
上一切都按預期工作,但是當我將它移至生產時,某些視圖會返回HTTP 500錯誤。
展望uWSGI日誌我得到的是這樣的:在這裏
** View: booking_accept_view 6zN6
[pid: 1959|app: 0|req: 7/7] xxx.xxx.xxx.xxx() {56 vars in 1339 bytes}
[Thu Jun 11 10:00:39 2015] GET /tidsbestilling/admin-accept/6zN6/ =>
generated 27 bytes in 28 msecs (HTTP/1.1 500)
6 headers in 226 bytes (2 switches on core 0)
所以沒有太大的幫助。
nginx的訪問日誌:
xxx.xxx.xxx.xxx - - [11/Jun/2015:10:00:39 +0200]
"GET /tidsbestilling/admin-accept/6zN6/ HTTP/1.1" 500 38
"https://example.com/tidsbestilling/admin-details/6zN6/"
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.10
(KHTML, like Gecko) Version/8.0.7 Safari/600.7.10"
在Nginx的錯誤日誌中沒有記錄。
我試圖在try-except
塊中附上,但是我沒有收到任何消息。
我的看法是這樣的:
def booking_admin_accept_view(request, booking_uid):
print("** View: booking_accept_view", booking_uid)
user = request.user
if not (user is not None and user.is_authenticated() and user.is_active):
return HttpResponseRedirect(reverse('booking_admin_login_view'))
try:
booking = Booking.objects.get(uid=booking_uid)
booking.status = 'accepted'
booking.save()
send_sms(booking)
return HttpResponseRedirect(reverse('booking_admin_details_view', args=(booking_uid,)))
except(Exception, e):
logging.exception(e)
的booking.save()
被執行,如果我做一個./manage.py shell
,我可以做send_sms(booking)
和工作過,但認爲不會走到這一步。
所以我的問題是:我如何獲得更多有關錯誤的信息?我真的必須以DEBUG模式運行以獲取信息嗎?
您提到了uWSGI日誌...您是否檢查了Nginx日誌? – rnevius
django記錄了500個錯誤。它會說什麼嗎? –
@rnevius:我在問題中放入了nginx訪問日誌條目,但這裏沒有太多幫助。 – henrikstroem