gpt4 book ai didi

Python 定时轮播日志

转载 作者:太空宇宙 更新时间:2023-11-04 04:39:41 25 4
gpt4 key购买 nike

在标有“TimedRotatingLogs”的部分要求对这篇文章进行一些澄清:https://www.blog.pythonlibrary.org/2014/02/11/python-how-to-create-rotating-logs/

    handler = TimedRotatingFileHandler(path,
when="m",
interval=1,
backupCount=5)

我对这部分特别好奇。在查看文章时,它说“WeekDay”做“w0-w6”。会像这样吗? :

        handler = TimedRotatingFileHandler(path,
when="w",
interval=0,
backupCount=5)

或者它看起来像:

 handler = TimedRotatingFileHandler(path,
when="w0",
interval=1,
backupCount=5)

并解释为什么一个比另一个好

最佳答案

根据 Kite Docs 上的文章.它指出

When using weekday-based rotation, specify ‘W0’ for Monday, ‘W1’ for Tuesday, and so on up to ‘W6’ for Sunday. In this case, the value passed for interval isn’t used.

所以从那里开始你的情况下的代码是

handler = TimedRotatingFileHandler(path, when="w0", backupCount=5)

关于Python 定时轮播日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50955451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com