Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.5上带有bandersnatch的Python日志记录配置文件_Python_Logging_Python 3.5 - Fatal编程技术网

Python 3.5上带有bandersnatch的Python日志记录配置文件

Python 3.5上带有bandersnatch的Python日志记录配置文件,python,logging,python-3.5,Python,Logging,Python 3.5,我正在使用Python3.5的最新版本创建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日志配置,取消了上面这

我正在使用Python3.5的最新版本创建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日志配置,取消了上面这行的注释,并创建了这个日志配置:

[loggers]
keys=root

[handlers]
keys=logfile

[formatters]
keys=logfileformatter

[logger_root]
level=NOTSET
handlers=logfile

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

[handler_logfile]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=logfileformatter
args=('/path/to/bandersnatch.log','a',10485760,5)    
现在bandersnatch不再向stdout生成任何输出,并且已经创建了我指定的日志文件,但是没有记录任何内容

我尝试了两种指定日志级别的NOTSET和DEBUG的不同组合,但在运行bandersnatch时还没有记录任何内容


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

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

[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

希望有帮助

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

[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
希望有帮助