LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
# Include the default Django email handler for errors
# This is what you'd get without configuring logging at all.
'mail_admins': {
'class': 'django.utils.log.AdminEmailHandler',
'level': 'ERROR',
# But the emails are plain text by default - HTML is nicer
'include_html': True,
},
# Log to a text file that can be rotated by logrotate
'logfile': {
'class': 'logging.handlers.WatchedFileHandler',
'filename': '/var/log/django/myapp.log'
},
},
'loggers': {
# Again, default Django configuration to email unhandled exceptions
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
# Might as well log any errors anywhere else in Django
'django': {
'handlers': ['logfile'],
'level': 'ERROR',
'propagate': False,
},
# Your own app - this assumes all your logger names start with "myapp."
'myapp': {
'handlers': ['logfile'],
'level': 'WARNING', # Or maybe INFO or DEBUG
'propagate': False
},
},
}
-
setting.py에 아래와 같은 코드를 추가한다.
출처 https://stackoverflow.com/questions/238081/how-do-you-log-server-errors-on-django-sites
'2017년 > Python' 카테고리의 다른 글
redis (0) 2017.11.22 장고 ajax통신 코드 (0) 2017.11.16 장고 view,url (0) 2017.11.15 python anywhere 사용하기 (0) 2017.11.15 장고 모델 ,관리자 (0) 2017.11.15