# $request\_length outside of log module

**URL:** <https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365>\
**Category:** NGINX\
**Created:** [January 28, 2013, 2:59pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365 "2013-01-28T14:59:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [January 28, 2013, 2:59pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365/1 "2013-01-28T14:59:49Z")

</div>

Hi  
Over time you have been adding functionality to use log variables  
outside of log module, e.g.

Changes with nginx 1.3.8 30 Oct 2012  
\*) Feature: the $bytes\_sent, $connection, and $connection\_requests  
variables can now be used not only in the “log\_format” directive.

Changes with nginx 1.3.9 27 Nov 2012  
\*) Feature: the $request\_time and $msec variables can now be used not  
only in the “log\_format” directive.

Are you going to add the $request\_length variable to this list too?

Many thanks

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [January 28, 2013, 3:05pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365/2 "2013-01-28T15:05:39Z")

</div>

On 28 January 2013 13:56, Richard K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> in the “log\_format” directive.
> 
> Are you going to add the $request\_length variable to this list too?

I would think you could get something equivalent and useful out of  
$upstream\_http\_content\_length, as per  
[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpUpstreamModule#.24upstream_http_.24HEADER) .  
YMMV.

–  
Jonathan M. // Oxford, London, UK

> **[Jonathan Matthews :: Words Typed, Great Rates For Cash](https://www.jpluscplusm.com)**

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [January 28, 2013, 3:17pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365/3 "2013-01-28T15:17:56Z")

</div>

Hi,  
It’s not the same, $request\_length is the length of what the client  
(browser) sent it’s request for a file e.g. request headers, request  
body  
I suppose I could loop through the headers and body and count their  
lengths… but not ideal

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [January 28, 2013, 3:21pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365/4 "2013-01-28T15:21:27Z")

</div>

Hello!

On Mon, Jan 28, 2013 at 01:56:46PM +0000, Richard K. wrote:

> not only in the “log\_format” directive.
> 
> Are you going to add the $request\_length variable to this list too?

It’s already done:

[http://trac.nginx.org/nginx/changeset/5011/nginx](http://trac.nginx.org/nginx/changeset/5011/nginx)

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [January 28, 2013, 3:39pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365/5 "2013-01-28T15:39:34Z")

</div>

yeah, it’s different (correct) definition here:  
[http://nginx.org/en/docs/http/ngx\_http\_log\_module.html#log\_format](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format)  
should probably update wiki to reflect it

I think $http\_content\_length will give the length of the response also  
(not the request)

As Maxim says, they added it to the trunk a few days ago and I don’t  
mind waiting for next release 🙂

Thanks all

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [January 28, 2013, 3:24pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365/6 "2013-01-28T15:24:57Z")

</div>

On 28 January 2013 14:15, Richard K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> lengths.. but not ideal  
> My bad - I misread your original email.

$request\_length is actually defined here  
([GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpLogModule#log_format)) as the request  
/body/'s length, i.e. not counting headers. You might get something  
useful out of $http\_content\_length instead.

## Jonathan

Jonathan M. // Oxford, London, UK

> **[Jonathan Matthews :: Words Typed, Great Rates For Cash](https://www.jpluscplusm.com)**

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [January 28, 2013, 3:46pm UTC](https://www.ruby-forum.com/t/request-length-outside-of-log-module/229365/7 "2013-01-28T15:46:35Z")

</div>

On 28 January 2013 14:38, Richard K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> yeah, it’s different (correct) definition here:  
> [Module ngx\_http\_log\_module](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format)  
> should probably update wiki to reflect it

Ah yes, you’re right. Haven’t see a doc/wiki mismatch like that before!

> I think $http\_content\_length will give the length of the response also (not  
> the request)

I don’t think it will.  
[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpCoreModule#.24http_HEADER) says it’ll be the  
request header.

I hadn’t noticed $sent\_http\_\* before - handy!

## Jonathan

Jonathan M. // Oxford, London, UK

> **[Jonathan Matthews :: Words Typed, Great Rates For Cash](https://www.jpluscplusm.com)**
