美文网首页
python logging模块

python logging模块

作者: 简书说我的昵称违规 | 来源:发表于2017-06-16 10:45 被阅读17次

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'

相关文章

网友评论

      本文标题:python logging模块

      本文链接:https://www.haomeiwen.com/subject/bimpqxtx.html