# View body content in logs on POST requests

**URL:** https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185
**Category:** Gatling (Open-Source)
**Created:** [November 30, 2012, 11:24am UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185 "2012-11-30T11:24:27Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Loic\_Descotte](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@Loic\_Descotte](https://community.gatling.io/u/Loic_Descotte)
#### Post date: [November 30, 2012, 11:24am UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/1 "2012-11-30T11:24:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)
#### Post date: [November 30, 2012, 1:29pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/2 "2012-11-30T13:29:20Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![Loic\_Descotte](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@Loic\_Descotte](https://community.gatling.io/u/Loic_Descotte)
#### Post date: [November 30, 2012, 1:42pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/3 "2012-11-30T13:42:57Z")

</div>

Thanks it’s exactly what I needed!

Loic

---

<div class="post-metadata">

### Author: ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)
#### Post date: [November 30, 2012, 2:24pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/4 "2012-11-30T14:24:23Z")

</div>

For the record:  
[https://github.com/excilys/gatling/issues/847](https://github.com/excilys/gatling/issues/847)

[https://github.com/excilys/gatling/issues/848](https://github.com/excilys/gatling/issues/848)

---

<div class="post-metadata">

### Author: ![Tejas\_Shah1](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Tejas\_Shah1](https://community.gatling.io/u/Tejas_Shah1)
#### Post date: [February 28, 2013, 12:52pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/5 "2013-02-28T12:52:37Z")

</div>

Hi,

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

---

<div class="post-metadata">

### Author: ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)
#### Post date: [February 28, 2013, 12:57pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/6 "2013-02-28T12:57:02Z")

</div>

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](https://github.com/excilys/gatling/wiki/Configuration#wiki-config-files)

---

<div class="post-metadata">

### Author: ![Chiya](https://avatars.discourse-cdn.com/v4/letter/c/3ab097/32.png) [@Chiya](https://community.gatling.io/u/Chiya)
#### Post date: [October 14, 2013, 6:47pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/7 "2013-10-14T18:47:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)
#### Post date: [October 14, 2013, 6:54pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/8 "2013-10-14T18:54:29Z")

</div>

Hi,

Look at the documentation: [https://github.com/excilys/gatling/wiki/HTTP#wiki-custom-dump](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](https://github.com/excilys/gatling/wiki/HTTP#wiki-protocol-config)

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

---

<div class="post-metadata">

### Author: ![Maxence\_Warzecha](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@Maxence\_Warzecha](https://community.gatling.io/u/Maxence_Warzecha)
#### Post date: [December 12, 2013, 8:28pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/9 "2013-12-12T20:28:55Z")

</div>

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 : [GitHub - gatling/gatling: Modern Load Testing as Code](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

---

<div class="post-metadata">

### Author: ![Raja\_Thumati](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@Raja\_Thumati](https://community.gatling.io/u/Raja_Thumati)
#### Post date: [October 13, 2014, 1:08pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/10 "2014-10-13T13:08:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Raja\_Thumati](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@Raja\_Thumati](https://community.gatling.io/u/Raja_Thumati)
#### Post date: [October 13, 2014, 1:11pm UTC](https://community.gatling.io/t/view-body-content-in-logs-on-post-requests/185/11 "2014-10-13T13:11:17Z")

</div>

sorry here is my attachment.

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

[HTTP request.docx](https://community.gatling.io/uploads/short-url/4wnNoULAG4SQ0BwVwoohtOW87kL.docx) (13.4 KB)
