日志系统-应用

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,
},
}
}

 

 

 

 

 

 




posted @   FFLYY  阅读(22)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2019-11-18 面试-JWT认证
2019-11-18 面试 DRF-认证 权限 频率
2019-11-18 面试-cookie session token
2019-11-18 面试-hystack全文检索
2019-11-18 面试-restful规范
点击右上角即可分享
微信分享提示