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 pytest catchlog是否支持记录到多个文件_Python_Logging_Pytest - Fatal编程技术网

Python pytest catchlog是否支持记录到多个文件

Python pytest catchlog是否支持记录到多个文件,python,logging,pytest,Python,Logging,Pytest,pytest.ini如下所示: [pytest] log_cli = 1 log_cli_level = CRITICAL log_cli_format = %(message)s log_file = debug.log log_file_level = DEBUG log_file_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) log_file_date_format=%Y-%m-%d

pytest.ini如下所示:

[pytest]
log_cli = 1
log_cli_level = CRITICAL
log_cli_format = %(message)s

log_file = debug.log
log_file_level = DEBUG
log_file_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)
log_file_date_format=%Y-%m-%d %H:%M:%S
有没有办法根据日志文件级别指定要登录的文件?我希望有多个日志(debug.log、info.log、error.log等),并且每个文件都将包含指定日志级别或更高级别的日志

像这样的

[pytest]
log_cli = 1
log_cli_level = CRITICAL
log_cli_format = %(message)s

log_file = debug.log
log_file_level = DEBUG
log_file_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)
log_file_date_format=%Y-%m-%d %H:%M:%S

log_file = info.log
log_file_level = INFO
log_file_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)
log_file_date_format=%Y-%m-%d %H:%M:%S
但是,这不起作用,因为pytest.ini中不能有重复的名称


我尝试的另一个插件是pytest logger,但我不太喜欢它

不幸的是,这目前是不可能的。不幸的是,这目前是不可能的。