https://www.cnblogs.com/jiangchunsheng/p/8986452.html

https://www.cnblogs.com/jeavy/p/10926197.html

BASE_LOG_DIR = os.path.join(BASE_DIR, "log")
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '[%(asctime)s][%(threadName)s:%(thread)d][task_id:%(name)s][%(filename)s:%(lineno)d]'
'[%(levelname)s][%(message)s]'
},
'simple': {
'format': '[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d]%(message)s'
},
'collect': {
'format': '%(message)s'
}
},
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'filters': ['require_debug_true'], # 只有在Django debug为True时才在屏幕打印日志
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'SF': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,根据文件大小自动切
'filename': os.path.join(BASE_LOG_DIR, "xxx_info.log"), # 日志文件
'maxBytes': 1024 * 1024 * 50, # 日志大小 50M
'backupCount': 3, # 备份数为3 xx.log --> xx.log.1 --> xx.log.2 --> xx.log.3
'formatter': 'standard',
'encoding': 'utf-8',
},
'TF': {
'level': 'INFO',
'class': 'logging.handlers.TimedRotatingFileHandler', # 保存到文件,根据时间自动切
'filename': os.path.join(BASE_LOG_DIR, "xxx_info.log"), # 日志文件
'backupCount': 3, # 备份数为3 xx.log --> xx.log.2018-08-23_00-00-00 --> xx.log.2018-08-24_00-00-00 --> ...
'when': 'D', # 每天一切, 可选值有S/秒 M/分 H/小时 D/天 W0-W6/周(0=周一) midnight/如果没指定时间就默认在午夜
'formatter': 'standard',
'encoding': 'utf-8',
},
'error': {
'level': 'ERROR',
'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切
'filename': os.path.join(BASE_LOG_DIR, "xxx_err.log"), # 日志文件
'maxBytes': 1024 * 1024 * 5, # 日志大小 50M
'backupCount': 5,
'formatter': 'standard',
'encoding': 'utf-8',
},
'collect': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切
'filename': os.path.join(BASE_LOG_DIR, "xxx_collect.log"),
'maxBytes': 1024 * 1024 * 50, # 日志大小 50M
'backupCount': 5,
'formatter': 'collect',
'encoding': "utf-8"
}
},
'loggers': {
'': { # 默认的logger应用如下配置
'handlers': ['SF', 'console', 'error'], # 上线之后可以把'console'移除
'level': 'DEBUG',
'propagate': True,
},
'collect': { # 名为 'collect'的logger还单独处理
'handlers': ['console', 'collect'],
'level': 'INFO',
}
},
}

django logger转载的更多相关文章

  1. Django线上部署教程:腾讯云+Ubuntu+Django+Uwsgi(转载)

    网站名称: 向东的笔记本 本文链接: https://www.eastnotes.com/post/29 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议.转载请注明出处! ...

  2. django logging日志优先级

    原创博文 转载请注明出处! 参考官方文档:https://docs.djangoproject.com/en/2.1/topics/logging/ Loggers¶ A logger is the ...

  3. Python之Django环境搭建(MAC+pycharm+Django++postgreSQL)

    Python之Django环境搭建(MAC+pycharm+Django++postgreSQL) 转载请注明地址:http://www.cnblogs.com/funnyzpc/p/7828614. ...

  4. django日志,django-crontab,django邮件模块

    django 日志 四大块,格式器,过滤器,处理器,日志管理器 LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatt ...

  5. Django日志系统

    在Django中使用的日志系统是基于Python中的loggin模块. 首先简单介绍下logging. 一 Loggin模块简介 loggin模块主要包含以下四个部分: Loggers        ...

  6. django日志的设置

    关于django的日志设置详细可以看下官方文档:https://yiyibooks.cn/xx/Django_1.11.6/topics/logging.html 示例: # 日志文件配置 LOGGI ...

  7. django 自定义日志配置

    如果不想使用 python 的 dictConfig 格式来配置 logger,可以制定自己的配置架构. LOGGING_CONFIG 配置定义了用来配置 django logger 的可调用函数,默 ...

  8. Django日志器的使用

    Logging Mudel A quick logging primer Django uses Python’s builtin logging module to perform system l ...

  9. Django日志记录详细的报错信息

    当服务器500错误的时候,普通日志只会记录一行500的request信息,并不会记录详细的报错定位 [ERROR] 2019-06-12 15:07:03,597 "GET /api/v1/ ...

随机推荐

  1. Gym101667 H. Rock Paper Scissors

    将第二个字符串改成能赢对方时对方的字符并倒序后,字符串匹配就是卷积的过程. 那么就枚举字符做三次卷积即可. #include <bits/stdc++.h> struct Complex ...

  2. 0x00 Wechall writeup

    目录 0x00 Wechall writeup Training: Get Sourced Training: ASCII Encodings: URL Training: Stegano I Tra ...

  3. Nginx主配置文件说明

    #运行用户 user nobody; #启动进程,通常设置成和cpu的数量相等 worker_processes ; #全局错误日志及PID文件 #error_log logs/error.log; ...

  4. CF1175F The Number of Subpermutations

    题目链接 题意 给出一个长度为\(n\)的序列\(a\),问有多少个区间\([l,r]\)满足:在区间\([l,r]\)内,\([1,r-l+1]\)的每个整数都恰好出现了一次. \(n \le 3 ...

  5. nowcoder911L 最优子区间

    题目链接 思路 用\(f(i,j)\)表示前i个元素,以i为右端点,j为左端点时的答案. 用个"区间修改,单点查询"的线段树维护出第二维.在从左往右枚举i的过程中.将\([lst_ ...

  6. ORB-SLAM2初步

    一.ORB-SLAM简介 最近开始入坑SLAM,经过简单调研,各位大咖认为,目前最优秀的视觉SLAM系统是ORB-SLAM2,因此对ORB-SLAM2进行了学习. ORB-SLAM2是2015年提出的 ...

  7. [LeetCode] 918. Maximum Sum Circular Subarray 环形子数组的最大和

    Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty ...

  8. [LeetCode] 239. Sliding Window Maximum 滑动窗口最大值

    Given an array nums, there is a sliding window of size k which is moving from the very left of the a ...

  9. [LeetCode] 235. Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最小共同父节点

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  10. WPF DataGrid 鼠标对表格双击导致客户端崩溃

    该问题是由于在创建DataGrid时没有设置为只读属性 解决:             <DataGrid Name="switchInfoList" MouseLeftBu ...