如何在Tornado中使用定时旋转文件处理程序记录日志? [英] How to logging with timed rotate file handler in Tornado?
问题描述
我问了一个问题(如何在Tornado中管理nohup.out文件),了解如何在运行Tornado Web服务时自动处理nohup.out文件.
I've asked a question (how to manage nohup.out file in Tornado) about how to handle nohup.out file automatically when running a Tornado web service.
然后,我决定使用Tornado的logging
模块来编写我的日志文件.我了解了Tornado的文档.它提供的日志记录模块没有TimedRotatingFileHandler
,我仍然无法将日志文件作为日期进行管理.
And I decided to use the logging
module of Tornado to write my log files. I read about the documents of Tornado. The logging module it provides doesn't have the TimedRotatingFileHandler
, I still cannot manage the logging files as dates.
所以我想知道如何在Tonado的日志记录模块中使用TimedRotatingFileHandler
?
So I want to know how to use TimedRotatingFileHandler
in the logging module of Tonado?
推荐答案
我在安装Tornado时会旋转日志文件.
I have rotating log files with my Tornado install.
我在Tornado应用程序启动时添加以下日志记录配置行:
I add this logging config line at the Tornado app startup:
logging.config.dictConfig(yaml.load(open('logging.yaml', 'r')))
,然后包含一个类似于此要点的 .yaml:
and then include a logging.yaml that looks something like this gist:
这篇关于如何在Tornado中使用定时旋转文件处理程序记录日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!