python logging模块

logging level

Level Numeric value
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
NOTSET 0

value 值越大等级越高

logging config

version: 1

loggers:
  root:
    level: DEBUG
    handlers: [console]
  tornado:
    level: DEBUG
    handlers: [console,log]
    propagate: no
  tornado.access:
    level: DEBUG
    handlers: [console, access]
    propagate: no
  log:
    level: DEBUG
    handlers: [console,log]
    propagate: no

formatters:
  simple:
    format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
  timedRotating:
    format: '%(asctime)s %(name)-12s %(levelname)-8s - %(message)s'

handlers:
  console:
    class: logging.StreamHandler
    level: DEBUG
    formatter: simple
  access:
    class: logging.handlers.TimedRotatingFileHandler
    level: DEBUG
    formatter: simple
    filename: 'logs/access.log'
    when: 'midnight'
    interval: 1
    backupCount: 180
  log:
    class: logging.handlers.TimedRotatingFileHandler
    level: DEBUG
    formatter: timedRotating
    filename: 'logs/log.log'
    when: 'midnight'
    interval: 1
    backupCount: 180
    encoding: 'utf8'
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Logging 模块<a id="sec-1" name="sec-1"></a> 简介<a id="sec-1-...
    Nisen阅读 763评论 0 2
  • Python logging 模块 参考 http://blog.csdn.net/zyz511919766/ar...
    ktide阅读 954评论 0 2
  • 本文章是我大概三年前,在上家单位使用 Python 工作时结合官方文档做的整理。现在 Python 官方文档听说已...
    好吃的野菜阅读 217,618评论 14 232
  • Logging框架主要作用是Python里面处理日志 一.logging模块的组成 loggers :提供应用程...
    YichenWong阅读 1,584评论 1 0
  • 梦见的人 无处安放 是谁的想念 渗透了整夜 是谁的心事 封锁了时间 我不曾回头 也未去伸手 掐住了喉咙 独自承受 ...
    Zing13阅读 164评论 0 2