Kan_Wu  
                
                  
                    January 24, 2014,  9:26pm
                   
                  1 
               
             
            
              Hey Stéphane,
I want to do something like this but could not find out a complete solution.
I want to record or print response info (status, request, response content) only when an error happens, for example, 500 or 403, etc.
i know this one may work https://github.com/excilys/gatling/wiki/Gatling-2#wiki-http-misc , extraInfoExtractor(Status, Session, Request, Response) => List[Any]]
so i just add a global check in httpConf, and check status code? i dont think there is a doIf in check tho.
Any help will be appreciated.
Thanks,
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    January 24, 2014,  9:54pm
                   
                  2 
               
             
            
              how about this way:
.check(status.in(400 to 510).dontValidate.bodyString.print?)
i know i can get that by enable debug log, that will print too much other info that i dont want. and if i want both request body and response body, i guess i have to extraInfoExtractor?
在 2014年1月24日星期五UTC-8下午1时26分34秒,Kan Wu写道:
             
            
              
            
           
          
            
            
              Yeah, you have to go with extraInfoExtractor
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    October 23, 2014,  5:09pm
                   
                  4 
               
             
            
              I just come back to this topic with Gatling 2.0.1
I saw there’s something like extraInfoExtractor available http://gatling.io/docs/2.0.1/http/http_protocol.html#dumping-custom-data . but I think that is only dump data to log file? What if I just want to print that in console.
.extraInfoExtractor {
but scala gave me error like “type mismatch; found : Unit required: List[Any]”. I think the reason is Gatling is looking for List[Any] to add to log. Any ideas how I can set the print at global level? I do not want to add this for every single request.
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    October 23, 2014,  8:44pm
                   
                  5 
               
             
            
              this is working but it prints to simulation.log:
.extraInfoExtractor {
how can I make it print to console?
Thanks
             
            
              
            
           
          
            
            
              .extraInfoExtractor {
}
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    October 23, 2014,  8:51pm
                   
                  7 
               
             
            
              Good idea. This works fine. Sorry, I’m new to Scala. Thank you a lot!
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    October 23, 2014, 11:32pm
                   
                  8 
               
             
            
              here is some more code, this will only print out error response once if it’s the same request with the same error code.
var errorSet = scala.collection.immutable.HashSet("")
val httpConf = http
             
            
              
            
           
          
            
            
              See conf/logback.xml, you can just uncomment a logger there to achieve this.
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    October 24, 2014,  6:01am
                   
                  10 
               
             
            
              That’s not the same, it will print out much more than I need. And I just want it to be printed once. Print every time is too messy.
             
            
              
            
           
          
            
            
              Hi all
I’m using the code that was posted here, but the message is only making it to the console for GET requests, not for POSTs.
The following http object is used for both POSTs and GETs:
val httpConf = http
{
I know the POSTs are getting errors, but nothing is being printed.
Thanks
             
            
              
            
           
          
            
              
                Excilys  
              
                  
                    October 31, 2014,  9:14am
                   
                  12 
               
             
            
              That probably means that your code is wrong and doesn’t contain errorLable
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    October 31, 2014,  5:48pm
                   
                  13 
               
             
            
              if it’s at http conf level, should that be applied to both post and get? I dont see any reason that it can only print get but not post. A possible bug in Gatling?
             
            
              
            
           
          
            
              
                Excilys  
              
                  
                    November 3, 2014,  9:34pm
                   
                  14 
               
             
            
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    November 3, 2014,  9:36pm
                   
                  15 
               
             
            
              Good idea. but will disableResponseChunksDiscarding affect overall performance?
             
            
              
            
           
          
            
              
                Excilys  
              
                  
                    November 3, 2014,  9:39pm
                   
                  16 
               
             
            
              Maybe, maybe not, it depends on your test case.
             
            
              
            
           
          
            
              
                Kan_Wu  
              
                  
                    November 3, 2014,  9:40pm
                   
                  17 
               
             
            
              sounds good. even if it affects performance, we can just add more load generators. Thanks for the catch!