【问题标题】:How to configure logging handler to produce weekly rotated log files?如何配置日志记录处理程序以生成每周轮换的日志文件?
【发布时间】:2012-12-27 14:47:53
【问题描述】:
TimedRotatingFileHandler(filename, when='W', interval=0, backupCount=0)

生产:

ValueError: Unable to configure handler 'fichierSemaineStandard': You must specify a day for weekly rollover from 0 to 6 (0 is Monday): W

但是python documentation 告诉我们

值:'W',间隔类型:工作日(0=星期一)

那怎么了?

【问题讨论】:

    标签: python logging


    【解决方案1】:

    这部分文档似乎对此并不清楚。在查看代码后,要使周轮换工作,“W”参数是不够的。工作日编号必须紧跟字母W

    TimedRotatingFileHandler(filename, when='W0', backupCount=0)
    

    请注意,“间隔”参数是无用的。

    【讨论】:

      猜你喜欢
      • 2019-02-20
      • 2021-11-01
      • 2018-04-29
      • 1970-01-01
      • 2019-03-17
      • 2010-09-13
      • 2020-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多