View body content in logs on POST requests

Hi all,

is it possible to see the content of a POST request in the logs?
I have some 500 errors and I’m getting data from a big jdbc feeder. If I activate logs I can see errors like :

status=
500 Internal Server Error

headers= …

But I would like to see the body content for each failed request, to see if the content was wrong or if the server is not able to respond

Thanks,

Loic

We could print more info on debug level, but that would considerably slow down the engine. So I agree this could be interesting, but mainly for debugging purpose.

Have you tried using the extractor hooks:
https://github.com/excilys/gatling/wiki/HTTP#wiki-custom-dump

You could write something like:

.responseInfoExtractor { response =>
if (response.getStatusCode != 200) {
val extendedResponse = response.asInstanceOf[com.excilys.ebi.gatling.http.response.ExtendedResponse] // will change hook signature so that you don’t have to cast
println(extendedResponse.request.getStringData) // search com.ning.http.client.Request for the data your interested in
}
Nil
}

Hope that helps,

Stéphane

Thanks it’s exactly what I needed!

Loic

For the record:
https://github.com/excilys/gatling/issues/847

https://github.com/excilys/gatling/issues/848

Hi,

This is how we can print response. Can you please let me know how to print request content ?

This WAS a way of logging.
If you read the thread, you’ll that I pointed some issues fixed in 1.4.0, meaning that they’ve been solved and shipped.

You now simply have to uncomment a logger in the logback.xml file. See https://github.com/excilys/gatling/wiki/Configuration#wiki-config-files

Hi STephane,

I tried to implement your code below but I am getting the error:
value responseInfoExtractor is not a member of com.excilys.ebi.gatling.http.request.builder.PostHttpRequestBuilder

I am using gatling 1.5. 2.

Hi,

Look at the documentation: https://github.com/excilys/gatling/wiki/HTTP#wiki-custom-dump
This is a sub-paragraph of https://github.com/excilys/gatling/wiki/HTTP#wiki-protocol-config

ie responseInfoExtractor is a HttpProtocol method, not a request one.

I got trouble to print reponses body in logs but finally find an easy way.

Here is my working configuration with gatling 1.5.2 :

  1. Base on this : https://github.com/excilys/gatling/wiki/HTTP#disableresponsechunksdiscarding-since-130

Add **.disableResponseChunksDiscarding** on your httpConf object at the beginning of your Simulation.

  1. My current logback.xml
<?xml version="1.0" encoding="UTF-8"?>

%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx

false

gatling.log

%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx

true

Hope it helps someone googling like me.

Maxence

thank you Maxence Warzecha,
it is very helpful to me.

but in my case i am getting response in the console but i am unable to print it in file.

i am attaching my console response as word file…and my response is in red color…

so please help me on this…

any suggestions are helpful to me.

sorry here is my attachment.

i want to print that red color JSON(response body) into file

HTTP request.docx (13.4 KB)