# Logging POST data from $request\_body

**URL:** <https://www.ruby-forum.com/t/logging-post-data-from-request-body/202916>\
**Category:** NGINX\
**Created:** [February 8, 2011, 10:33pm UTC](https://www.ruby-forum.com/t/logging-post-data-from-request-body/202916 "2011-02-08T22:33:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 8, 2011, 10:33pm UTC](https://www.ruby-forum.com/t/logging-post-data-from-request-body/202916/1 "2011-02-08T22:33:15Z")

</div>

I have my config setup to handle a bunch of GET requests which render  
pixels that work fine to handle analytics and parse query strings for  
logging. With an additional third party data stream, I need to handle a  
POST request to a given url that has JSON in an expected loggable format  
inside of it’s request body. I don’t want to use a secondary server with  
proxy\_pass and just want to log the whole response into an associated  
log file like what it does with GET requests. A snippet of some code  
that I’m using looks like the following:

GET request (which works great):

```auto
location ^~ /rl.gif {
    set $rl_lcid $arg_lcid;
    if ($http_cookie ~* "lcid=(.*\S)")
    {
      set $rl_lcid $cookie_lcid;
    }

    empty_gif;
    log_format my_tracking '{ "guid" : "$rl_lcid", "data" :
"$arg__rlcdnsegs" }';
    access_log /mnt/logs/nginx/my.access.log my_tracking;
    rewrite ^(.*)$ http://my/url?id=$cookie_lcid? redirect;
  }
```

Here is kinda what I am trying to do:  
POST request (which does not work):

```auto
location /bk {
    log_format bk_tracking $request_body;
    access_log /mnt/logs/nginx/bk.access.log bk_tracking;
  }
```

Curling “curl [http://myurl/bk](http://myurl/bk) -d name=example” gives me a 404 page not  
found.

Then I tried:

```auto
location /bk.gif {
    empty_gif;
    log_format bk_tracking $request_body;
    access_log /mnt/logs/nginx/bk.access.log bk_tracking;
  }
```

Curling “curl [http://myurl/bk.gif](http://myurl/bk.gif) -d name=example” gives me a 405 Not  
Allowed.

My current version is nginx/0.7.62. Any help in the right direction is  
very much appreciated! Thanks!

Posted at Nginx Forum:

> **[Logging POST data from $request\_body](https://forum.nginx.org/read.php?2,173356,173356#msg-173356)**
>
> I have my config setup to handle a bunch of GET requests which render pixels that work fine to handle analytics and parse query strings for logging. With an additional third party data stream, I need to handle a POST request to a given url that has...
