时间:2021-07-01 10:21:17 帮助过:160人阅读
# logging.yaml version: 1 disable_existing_loggers: false formatters: simple: format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' loggers: all: handlers: [all] propagate: false tornado: handlers: [all] propagate: false handlers: console: class: logging.StreamHandler level: INFO formatter: simple stream: ext://sys.stdout all: class: logging.handlers.TimedRotatingFileHandler level: INFO formatter: simple when: midnight filename: ./logs/server.log root: level: INFO handlers: [console, all] propagate: true
只需在Tornado的入口代码处调用:
logging.config.dictConfig(yaml.load(open('logging.yaml', 'r')))