增加日志和报错
This commit is contained in:
@@ -14,7 +14,11 @@ import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
LOG_PATH = os.path.join(BASE_DIR, 'log')
|
||||
# 如果地址不存在,则自动创建log文件夹
|
||||
# print(1)
|
||||
# if os.path.exists(LOG_PATH):
|
||||
# os.mkdir(LOG_PATH)
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
|
||||
@@ -114,7 +118,61 @@ USE_L10N = True
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
LOGGING = {
|
||||
# version只能为1,定义了配置文件的版本,当前版本号为1.0
|
||||
"version": 1,
|
||||
# True表示禁用logger
|
||||
"disable_existing_loggers": False,
|
||||
# 格式化
|
||||
'formatters': {
|
||||
'default': {
|
||||
'format': '%(levelno)s %(funcName)s %(module)s %(asctime)s %(message)s'
|
||||
},
|
||||
'simple': {
|
||||
'format': '%(levelno)s %(module)s %(created)s %(message)s'
|
||||
}
|
||||
},
|
||||
|
||||
'handlers': {
|
||||
'error_handlers': {
|
||||
'level': 'ERROR',
|
||||
# 日志文件指定为5M, 超过5m重新命名,然后写入新的日志文件
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
# 指定文件大小
|
||||
'maxBytes': 5 * 1024,
|
||||
# 指定文件地址
|
||||
'filename': os.path.join(LOG_PATH, "error.log"),
|
||||
'formatter': 'default'
|
||||
},
|
||||
'debug_handlers': {
|
||||
'level': 'DEBUG',
|
||||
# 日志文件指定为5M, 超过5m重新命名,然后写入新的日志文件
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
# 指定文件大小
|
||||
'maxBytes': 5 * 1024 * 1024,
|
||||
# 指定文件地址
|
||||
'filename': os.path.join(LOG_PATH, "debug.log"),
|
||||
'formatter': 'default'
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'error': {
|
||||
'handlers': ['error_handlers'],
|
||||
'level': 'ERROR'
|
||||
},
|
||||
'debug': {
|
||||
'handlers': ['debug_handlers'],
|
||||
'level': 'DEBUG'
|
||||
}
|
||||
},
|
||||
|
||||
# 'filters': {
|
||||
# 'require_debug_true': {
|
||||
# '()': 'django.utils.log.RequireDebugTrue',
|
||||
# },
|
||||
|
||||
# }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user