如何将每个API调用的日志存储在单独的文本文件中 [英] How to store logs for every API call in a separate text file
问题描述
我使用空手道按顺序进行API调用.我需要将API的此顺序流的API请求和响应存储在每个API调用的单独的文本文件中. 需要了解我如何实现这一目标.
Using Karate i am making API calls sequentially. I need to store API request and response for this sequential flow of APIs in separate text files for each API call. Need to understand how can i achieve this.
我尝试了将整个执行日志存储在一个文本文件中的logback.
I have tried logback which stores entire execution logs in a text file.
推荐答案
看看> c0> 这将给您请求".现在,使用一些自定义Java(或JS)代码,然后将所需内容写入文件.
Take a look at karate.prevRequest
which will give you the "request". Now use some custom Java (or JS) code and write whatever you want to a file.
我个人认为这是不必要的,因为空手道的HTML报告可以满足您的所有需求.如果有人要您这样做,请尝试说服该人此练习浪费时间.
I think personally it is un-necessary because Karate's HTML report has all that you need. If someone is asking you to do this, please try convince that person that this exercise is a waste of time.
这篇关于如何将每个API调用的日志存储在单独的文本文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!