日志系统-应用
settings.py配置
#日志系统
LOG_ROOT = os.path.join(BASE_DIR, 'logs')
if not os.path.exists(LOG_ROOT):
os.makedirs(LOG_ROOT)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': { #日志格式
'standard': {
'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] [%(module)s:%(funcName)s] [%(levelname)s]- %(message)s'},
'verbose': {
'format': '[%(asctime)s] %(levelname)s %(pathname)s line:%(lineno)s %(process)d [%(threadName)s] : %(message)s'
},
},
'handlers': { #处理器
"file":{
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR, 'logs/sto_bg.log'), #日志输出文件
'maxBytes': 1024 * 1024 * 5 * 10,
'backupCount': 5,
'formatter': 'verbose',
'encoding': 'utf-8'
},
"celery":{
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR, 'logs/celery_task.log'),
'maxBytes': 1024 * 1024 * 5 * 10,
'backupCount': 5,
'formatter': 'verbose',
'encoding': 'utf-8'
},
},
'loggers': { #logging管理器
"file":{
'handlers':['file'],
'level':'DEBUG',
'propagate': True
},
"celery":{
'handlers':['celery'],
'level':'DEBUG',
'propagate':True,
},
}
}


浙公网安备 33010602011771号