How to get rest-assured log into something printable in a text file

后端 未结 4 2252
攒了一身酷
攒了一身酷 2021-01-12 02:52

I\'m working into a method trying to change the default rest-assured log (which goes to the console) to a file using log4j.

It\'s a JUnit project which methods final

4条回答
  •  渐次进展
    2021-01-12 03:23

    PrintStream fileOutPutStream = new PrintStream(new File("somefile.txt"));
    RestAssured.config = config().logConfig(new LogConfig().defaultStream(fileOutPutStream)); 
    

    Use a printStream to point to a file & give a filename you want to print the log. Put the above code in your setup method for the tests & then just call log on your RequestSpecification instance as below

    requestSpecification.log().all();
    

提交回复
热议问题