JMeter - how to log the full request for a failed response?

后端 未结 4 555
无人共我
无人共我 2020-12-08 13:21

i\'m using JMeter command line to stress test our website api. Now, here\'s a sample result i\'m getting back:

Creating summariser 
Created th         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 13:55

    This is how I log the full request (request URL + request body) for failed requests.

    1. Add a Listener inside the Thread Group
    try{
      var message = "";
      var currentUrl = sampler.getUrl();
      message +=  ". URL = " +currentUrl;
      var requestBody = sampler.getArguments().getArgument(0).getValue();
      message += " --data " + sampler.getArguments();
    
      if(!sampleResult.isSuccessful()){
          log.error(message);
      }
    
    }catch(err){
      //do nothing. this could be a debug sampler. no need to log the error
    }
    

    For every Sampler inside the Thread Group, the Listener will execute this code after the Sampler.

提交回复
热议问题