Python pytest catchlog是否支持记录到多个文件
pytest.ini如下所示: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]
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,但我不太喜欢它不幸的是,这目前是不可能的。不幸的是,这目前是不可能的。