Yes :D I am writing a blog post on that: https://github.com/lazywithclass/lazywithclass.github.io/blob/master/2015-10-22/README.md#logging-request-body-in-haproxy Also because I am using the default log-format, so before adding the request body I will have to get the configuration string that defines it.
On Thu, 22 Oct 2015 at 11:12 Baptiste <[email protected]> wrote: > To share this information to everyone, here is what Alberot might have > done: > > global > log 127.0.0.1:514 local0 info > > defaults > log global > log-format "body: %[capture.req.hdr(0)]" > mode http > > frontend f > declare capture request len 8192 # id=0 to store request body > bind 127.0.0.1:8001 > http-request capture req.body id 0 > default_backend b > > backend b > server s 127.0.0.1:8000 > > > Log generated when a body is sent: > localhost haproxy[25012]: body: foo:bar > and when no body are sent: > localhost haproxy[25012]: body: - > > Baptiste > > > On Thu, Oct 22, 2015 at 10:30 AM, Alberto Zaccagni > <[email protected]> wrote: > > Sorry for skipping over that part, I thought I've understood what the > > example in http://blog.haproxy.com/2015/10/14/whats-new-in-haproxy-1-6/ > > meant, but I did not. > > I now get it and it worked, thanks Baptiste. > > > > Alberto > > > > On Thu, 22 Oct 2015 at 08:53 Baptiste <[email protected]> wrote: > >> > >> You might have missed the most important part of my previous mail, so > >> I'm repeating it again: > >> "Look for capture in this page > >> http://blog.haproxy.com/2015/10/14/whats-new-in-haproxy-1-6/ and use > >> it to capture the body at the request time and log it." > >> > >> Use req.body in the example and log the capture.req.hdr in your > >> log-format and your done. > >> > >> Baptiste > >> > >> > >> On Thu, Oct 22, 2015 at 9:09 AM, Alberto Zaccagni > >> <[email protected]> wrote: > >> > Hello Baptiste, > >> > > >> > I've read both the 1.6 announcement and the docs about this feature, > but > >> > u > >> > could not get it to work, I know I'm doing something wrong, I just > don't > >> > know what. > >> > I've posted my configuration in the previous email, here is it: > >> > https://gist.github.com/lazywithclass/d255bb4d2086b07be178 > >> > > >> > Thanks for your help > >> > > >> > Alberto > >> > > >> > > >> > On Wed, 21 Oct 2015, 9:58 p.m. Baptiste <[email protected]> wrote: > >> >> > >> >> Hi, > >> >> > >> >> I guess this is because the sample applies to a request element while > >> >> logging happens after the response has been sent, so data is not > >> >> available anymore. > >> >> Look for capture in this page > >> >> http://blog.haproxy.com/2015/10/14/whats-new-in-haproxy-1-6/ and use > >> >> it to capture the body at the request time and log it. > >> >> > >> >> If it still doesn't work, post your configuration. > >> >> > >> >> Baptiste > >> >> > >> >> > >> >> On Wed, Oct 21, 2015 at 5:31 PM, Alberto Zaccagni > >> >> <[email protected]> wrote: > >> >> > Did anyone succeeded in logging req.body? > >> >> > If so I would likely appreciate an example / some hints / a pointer > >> >> > into > >> >> > the > >> >> > docs, even though I've looked into this last one and could not find > >> >> > how > >> >> > to > >> >> > do it. > >> >> > > >> >> > Thank you > >> >> > > >> >> > Alberto > >> >> > > >> >> > On Fri, 16 Oct 2015 at 10:40 Alberto Zaccagni > >> >> > <[email protected]> wrote: > >> >> >> > >> >> >> Yes, I did turn it on. Or so I think, please have a look at my > >> >> >> configuration file: > >> >> >> https://gist.github.com/lazywithclass/d255bb4d2086b07be178 > >> >> >> > >> >> >> Thank you > >> >> >> > >> >> >> Alberto > >> >> >> > >> >> >> > >> >> >> On Fri, 16 Oct 2015 at 10:12 Baptiste <[email protected]> wrote: > >> >> >>> > >> >> >>> > >> >> >>> Le 16 oct. 2015 10:46, "Alberto Zaccagni" > >> >> >>> <[email protected]> a écrit : > >> >> >>> > > >> >> >>> > Hello, > >> >> >>> > > >> >> >>> > Sorry for the repost, but it's really not clear to me how to > use > >> >> >>> > this > >> >> >>> > feature: "Processing of HTTP request body" in > >> >> >>> > http://blog.haproxy.com/2015/10/14/whats-new-in-haproxy-1-6/, > can > >> >> >>> > it > >> >> >>> > be used > >> >> >>> > to log the body of a request? > >> >> >>> > > >> >> >>> > I am trying to use it like this in both my HTTP and HTTPS > >> >> >>> > frontends: > >> >> >>> > > >> >> >>> > option http-buffer-request > >> >> >>> > log-format "%[req.body]" > >> >> >>> > > >> >> >>> > The error I get is "'log-format' : sample fetch <req.body> may > >> >> >>> > not > >> >> >>> > be > >> >> >>> > reliably used here because it needs 'HTTP request headers' > which > >> >> >>> > is > >> >> >>> > not > >> >> >>> > available here.", where should I be using it? > >> >> >>> > Does that mean that we cannot log req.body at all or that I > have > >> >> >>> > to > >> >> >>> > enable another option before trying to use it? > >> >> >>> > > >> >> >>> > Any hint or help is much appreciated. > >> >> >>> > Thank you. > >> >> >>> > > >> >> >>> > Cheers > >> >> >>> > >> >> >>> Have you turned on 'mode http'? > >> >> >>> > >> >> >>> Baptiste >

