python3.5上使用bandersnatch的Python日志记录配置文件

2024-05-29 04:26:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用python3.5中最新的bandersnatch 2.0.0来创建一个PyPi镜像。Bandersnatch有一些相当稀疏的文档,但是在示例配置文件中,它说:

; Advanced logging configuration. Uncomment and set to the location of a
; python logging format logging config file.
; log-config = /etc/bandersnatch-log.conf

因此,我已经准备好了python日志记录配置,取消了上面这行的注释,并创建了以下日志配置:

^{pr2}$

现在bandersnatch不再向stdout生成任何输出,我指定的日志文件已经创建,但是没有任何日志记录。在

我尝试过对指定的两个日志级别使用不同的NOTSET和DEBUG组合,但是在运行bandersnatch时还没有记录任何内容。在

有什么想法吗?我所看到的所有其他问题都是编程错误或人们忘记为[logger_root]设置日志级别。我想我没有错过这些。在


Tags: 文档pypilogconfig示例镜像logging配置文件
1条回答
网友
1楼 · 发布于 2024-05-29 04:26:26

也许我回答得太晚了,但可能会有帮助。。。 该问题似乎与根记录器有关,您可以创建第二个记录器,如下所示:

[loggers]
keys=root,file

[handlers]
keys=root,file

[formatters]
keys=common

[logger_root]
level=NOTSET
handlers=root

[logger_file]
level=INFO
handlers=file
propagate=1
qualname=bandersnatch

[formatter_common]
format=%(asctime)s %(name)-12s: %(levelname)s %(message)s

[handler_root]
class=StreamHandler
level=DEBUG
formatter=common
args=(sys.stdout,) 

[handler_file]
class=handlers.RotatingFileHandler
level=INFO
formatter=common
args=('/path/to/bandersnatch.log','D',1,'UTF-8')
#will manage one file a day

希望有帮助!在

相关问题 更多 >

    热门问题