Django 로그 및 오류 위치
nginx로 django 서버를 설정했는데 일부 페이지에서 403 오류가 발생합니다.
장고 로그는 어디에서 찾을 수 있습니까? 오류를 자세히 볼 수있는 곳은 어디입니까?
로그 는 settings.py
파일에 설정 됩니다. 새로운 기본 프로젝트는 다음과 같습니다.
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
기본적으로 이들은 로그 파일을 생성하지 않습니다. 원하는 경우 filename
매개 변수를 추가해야 합니다.handlers
'applogfile': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': os.path.join(DJANGO_ROOT, 'APPNAME.log'),
'maxBytes': 1024*1024*15, # 15MB
'backupCount': 10,
},
이렇게하면 크기가 15MB이고 기록 버전 10 개를 유지할 수있는 회전 로그가 설정됩니다.
에서 loggers
위의 섹션, 당신은 추가 할 필요가 applogfile
받는 handlers
응용 프로그램에 대한
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'APPNAME': {
'handlers': ['applogfile',],
'level': 'DEBUG',
},
}
이 예제는 Django 루트의 로그를 APPNAME.log
에 추가 settings.py
:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'debug.log',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
And it will create a file called debug.log
in the root of your. https://docs.djangoproject.com/en/1.10/topics/logging/
Setup https://docs.djangoproject.com/en/dev/topics/logging/ and then these error's will echo where you point them. By default they tend to go off in the weeds so I always start off with a good logging setup before anything else.
Here is a really good example for a basic setup: https://ian.pizza/b/2013/04/16/getting-started-with-django-logging-in-5-minutes/
Edit: The new link is moved to: https://github.com/ianalexander/ianalexander/blob/master/content/blog/getting-started-with-django-logging-in-5-minutes.html
참고URL : https://stackoverflow.com/questions/19256919/location-of-django-logs-and-errors
'Program Tip' 카테고리의 다른 글
기본 new 및 delete 연산자를 대체하는 이유는 무엇입니까? (0) | 2020.11.21 |
---|---|
Dapper.Rainbow VS Dapper.Contrib (0) | 2020.11.21 |
SOAP 웹 서비스는 "POST"http 메소드 만 지원합니까? (0) | 2020.11.21 |
AzureWebJobsDashboard 연결 문자열 정보는 어디서 얻을 수 있나요? (0) | 2020.11.21 |
HashSet (0) | 2020.11.21 |