log
This commit is contained in:
parent
07959a996c
commit
e57249647d
|
@ -3,4 +3,4 @@ ENV = 'production'
|
|||
|
||||
# base api
|
||||
# VUE_APP_BASE_API = '/prod-api'
|
||||
VUE_APP_BASE_API = 'https://apitest.ctcshe.com'
|
||||
VUE_APP_BASE_API = 'http://apitest.ahctc.cn'
|
||||
|
|
|
@ -175,3 +175,84 @@ MEDIA_URL = '/media/'
|
|||
WORKFLOW_URL = "http://127.0.0.1:8888"
|
||||
WORKFLOW_TOKEN = "716a22f8-5d58-11ea-a5c7-1063c8f02116"
|
||||
WORKFLOW_APP="oa"
|
||||
|
||||
|
||||
# 日志配置
|
||||
# 创建日志的路径
|
||||
LOG_PATH = os.path.join(BASE_DIR, 'log')
|
||||
# 如果地址不存在,则自动创建log文件夹
|
||||
if not os.path.join(LOG_PATH):
|
||||
os.mkdir(LOG_PATH)
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
# 日志格式
|
||||
'standard': {
|
||||
'format': '[%(asctime)s] [%(filename)s:%(lineno)d] [%(module)s:%(funcName)s] '
|
||||
'[%(levelname)s]- %(message)s'},
|
||||
'simple': { # 简单格式
|
||||
'format': '%(levelname)s %(message)s'
|
||||
},
|
||||
},
|
||||
# 过滤
|
||||
'filters': {
|
||||
'require_debug_true': {
|
||||
'()': 'django.utils.log.RequireDebugTrue',
|
||||
},
|
||||
},
|
||||
# 定义具体处理日志的方式
|
||||
'handlers': {
|
||||
# 默认记录所有日志
|
||||
'default': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': os.path.join(LOG_PATH, 'all-{}.log'.format(datetime.datetime.now().strftime('%Y-%m-%d'))),
|
||||
'maxBytes': 1024 * 1024 * 5, # 文件大小
|
||||
'backupCount': 5, # 备份数
|
||||
'formatter': 'standard', # 输出格式
|
||||
'encoding': 'utf-8', # 设置默认编码,否则打印出来汉字乱码
|
||||
},
|
||||
# 输出错误日志
|
||||
'error': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': os.path.join(LOG_PATH, 'error-{}.log'.format(datetime.datetime.now().strftime('%Y-%m-%d'))),
|
||||
'maxBytes': 1024 * 1024 * 5, # 文件大小
|
||||
'backupCount': 5, # 备份数
|
||||
'formatter': 'standard', # 输出格式
|
||||
'encoding': 'utf-8', # 设置默认编码
|
||||
},
|
||||
# 控制台输出
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'standard'
|
||||
},
|
||||
# 输出info日志
|
||||
'info': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': os.path.join(LOG_PATH, 'info-{}.log'.format(datetime.datetime.now().strftime('%Y-%m-%d'))),
|
||||
'maxBytes': 1024 * 1024 * 5,
|
||||
'backupCount': 5,
|
||||
'formatter': 'standard',
|
||||
'encoding': 'utf-8', # 设置默认编码
|
||||
},
|
||||
},
|
||||
# 配置用哪几种 handlers 来处理日志
|
||||
'loggers': {
|
||||
# 类型 为 django 处理所有类型的日志, 默认调用
|
||||
'django': {
|
||||
'handlers': ['default', 'console'],
|
||||
'level': 'INFO',
|
||||
'propagate': False
|
||||
},
|
||||
# log 调用时需要当作参数传入
|
||||
'log': {
|
||||
'handlers': ['error', 'info', 'console', 'default'],
|
||||
'level': 'INFO',
|
||||
'propagate': True
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue