Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gatling - Log body of request in simulation.log or console

Tags:

I would like to see what is in the body of the post that I am sending in my script. In fact, I would like to see the request, request body and response. From looking at the docs and the forums, I see that I can uncomment a line in logback-test.xml which I did as shown below

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">     <resetJUL>true</resetJUL> </contextListener>  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">     <encoder>         <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>         <immediateFlush>false</immediateFlush>     </encoder> </appender>  <!-- Uncomment for logging ALL HTTP request and responses --> <logger name="io.gatling.http" level="TRACE" />  <!-- Uncomment for logging ONLY FAILED HTTP request and responses -->     <!--<logger name="io.gatling.http" level="DEBUG" /> -->   <root level="DEBUG">     <appender-ref ref="CONSOLE" /> </root> 

The simulation.log file nor the console shows me the request, response etc. After a bit of googling and reading documentation, I saw that I could do this -

.extraInfoExtractor(extraInfo => List(extraInfo.request, extraInfo.response,extraInfo.session)) 

This provides me with pretty much everything except the request body. How do I get the request body? I am trying to debug an issue where I am sure the body that is getting sent is not what I actually want.

like image 996
namesake Avatar asked Oct 23 '15 01:10

namesake


1 Answers

Add this to your logback.xml

<logger name="io.gatling.http.ahc" level="DEBUG" /> 

This will print following details for each failure -

  1. Request url
  2. Request header
  3. Request body
  4. Response header
  5. Gatling session data
like image 113
Bhushan Bhangale Avatar answered Sep 19 '22 10:09

Bhushan Bhangale