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

namesake picture namesake · Oct 23, 2015 · Viewed 27.6k times · Source

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.

Answer

Bhushan Bhangale picture Bhushan Bhangale · Feb 13, 2016

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