程序员看的格式

standard_format = '[%(asctime)s][%(threadName)s:%(thread)d][task_id:%(name)s][%(filename)s:%(lineno)d]'
'[%(levelname)s][%(message)s]' #其中name为getlogger指定的名字
logfile_path1 = "coder.log"

老板看的格式

simple_format = '[%(levelname)s][%(asctime)s]%(message)s'
logfile_path2 = "boss.log"

LOGGING_DIC = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': standard_format
},
'simple': {
'format': simple_format
},
},
'filters': {},
'handlers': {
#打印到终端的日志
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler', # 打印到屏幕
'formatter': 'simple'
},
#打印到文件的日志,收集info及以上的日志
'std': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler', # 保存到文件
'formatter': 'standard',
'filename': logfile_path1, # 日志文件
'maxBytes': 102410245, # 日志大小 5M
'backupCount': 5, #日志文件最大个数
'encoding': 'utf-8', # 日志文件的编码
},
'boss': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler', # 保存到文件
'formatter': 'simple',
'filename': logfile_path2, # 日志文件
'maxBytes': 1024 * 1024 * 5, # 日志大小 5M
'backupCount': 5, # 日志文件最大个数
'encoding': 'utf-8', # 日志文件的编码
}
},
'loggers': {
#logging.getLogger(name)拿到的logger配置
'aa': {
'handlers': ['std', 'console',"boss"], # 这里把上面定义的handler都加上,即log数据会同时输出到三个位置
'level': 'INFO',
'propagate': True, # 向上(更高level的logger)传递
},
},
}

08-02-loggin-模块的更多相关文章

  1. Python 自学基础(四)——time模块,random模块,sys模块,os模块,loggin模块,json模块,hashlib模块,configparser模块,pickle模块,正则

    时间模块 import time print(time.time()) # 当前时间戳 # time.sleep(1) # 时间延迟1秒 print(time.clock()) # CPU执行时间 p ...

  2. 〖Linux〗(2013.08.02)使用ctag+cscope查看Android源代码

    1. 安装ctags和cscope sudo apt-get install -y exuberant-ctags cscope 2. vimrc中的配置 """&quo ...

  3. Angular问题02 创建模块失败、 angular-cli名称问题、升级angular-cli

    1 创建模块失败 1.1 问题描述 利用 ng g m 模块名 创建新模块时出错 1.2 错误信息 1.3 问题原因 angular-cli 版本出现问题 1.4 解决办法 卸载掉之前使用的 angu ...

  4. Vue源码学习02 初始化模块init.js

    接上篇,我们看到了VUE分了很多模块(initMixin()stateMixin()eventsMixin()lifecycleMixin()renderMixin()),通过使用Mixin模式,都是 ...

  5. hashlib 和loggin模块

    1.摘要算法hashlib 1. md5加密 #1. 摘要算法 #md5加密算法 32位 import hashlib username ="alex" md5_obj =hash ...

  6. Murano Weekly Meeting 2016.08.02

    Meeting time: 2016.August.02 1:00~2:00 Chairperson:  Valerii Kovalchuk, from Mirantis Meeting summar ...

  7. 02 requests模块

    requests模块 requests是用python语言基于urllib编写的,采用的是Apache2 Licensed开源协议的HTTP库,requests会比urllib更加方便,可以节约我们大 ...

  8. python预课02 time模块,文本进度条示例,数字类型操作,字符串操作

    time模块 概述:time库是Python中处理时间的标准库,包含以下三类函数 时间获取: time(), ctime(), gmtime() 时间格式化: strftime(), strptime ...

  9. python之loggin模块与第三方模块

    目录 logging模块详解 第三方模块 openpyxl模块 logging模块详解 主要组成部分 logger对象,用于产生日志 # 第一步,创建logger对象 logger = logging ...

  10. UVA 465 (13.08.02)

     Overflow  Write a program that reads an expression consisting of twonon-negative integer and an ope ...

随机推荐

  1. 【InnoDB】体系结构

    一.概述: innodb的整个体系架构就是由多个内存块组成的缓冲池及多个后台线程构成.缓冲池缓存磁盘数据(解决cpu速度和磁盘速度的严重不匹配问题),后台进程保证缓存池和磁盘数据的一致性(读取.刷新) ...

  2. Ceph的正确玩法之Ceph纠删码理论与实践

    http://blog.itpub.net/31545808/viewspace-2637083/ 注意空格,有的命令少空格 随着云计算业务的快速发展,国内外云计算企业的专利之争也愈发激烈.在云计算这 ...

  3. Echarts mc地图

    Echarts mc地图 echarts官网实例: https://gallery.echartsjs.com/editor.html?c=xSNlA5O-zl 效果: 代码: <html> ...

  4. [NOIP模拟25]题解

    A.字符串 Catalan数不能再裸了 #include<cstdio> #include<iostream> #include<cstring> using na ...

  5. Qwidget布局操作之QGridLayout(网格布局)

    QMainWindow并没有setLayout()函数,因此不能使用setLayout()函数来设置layout,需要使用间接的方法. 需要做的只是先定义一个QWidget对象,然后使用QMainWi ...

  6. 线程类中使用spring注解报空指针异常

    springboot项目开发中,作为服务端,实现了线程类,在此类中添加spring注解@Source注入的service,报空指针异常. 查原因后,发现是线程中,不支持spring注解,因为sprin ...

  7. rsync+inotify实现实时同步案例

    转自:http://chocolee.blog.51cto.com/8158455/1400596 随着应用系统规模的不断扩大,对数据的安全性和可靠性也提出的更好的要求,rsync在高端业务系统中也逐 ...

  8. 2.Prometheus安装部署

    环境准备 2台Linux操作系统(基于centos7) docker环境 配置 IP 角色 版本 192.168.229.139 prometheus-server 2.10 192.168.229. ...

  9. 前端之间的url 传值

    转自:https://www.cnblogs.com/candy-Yao/p/8858166.html

  10. Netty教程

    Netty是一个java开源框架.Netty提供异步的.事件驱动的网络应用程序框架和工具,用以快速开发高性能.高可靠性的网络服务器和客户端程序. Netty是一个NIO客户端.服务端框架.允许快速简单 ...