Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to log request/response size(body+headers) in the access_log. Any idea how to do it in nginx? In apache we can do it using %I..%O...

share|improve this question
up vote 1 down vote accepted

I would use these 2 parameters in nginx.conf:

log_format perf '$remote_addr $status - $request_length $bytes_sent'

According to documentation ( the $request_length is only the body of the request, but I have confirmed that it includes all headers (I have some GET requests with lots of cookies which have more than 1400 bytes in total). $bytes_sent is total number of bytes sent to the client (as opposed to $body_sent which is compatible with apache %B).

share|improve this answer
Thanks for the reply.. – RJ01 Jan 5 '12 at 9:42

Reference, here: LOGMODULE

$body_bytes_sent, the number of bytes, transmitted to client minus the response headers. This variable is compatible with the %B parameter of Apache's mod_log_config (this was called $apache_bytes_sent, before version 0.3.10)

$bytes_sent, the number of bytes transmitted to client

$connection, the number of connection

$msec, the current time at the moment of writing the log entry (microsecond accuracy)

$pipe, "p" if request was pipelined

$request_length, the length of the body of the request

$request_time, the time it took nginx to work on the request, in seconds with millisecond precision (just seconds for versions older than 0.5.19)

$status, status of answer

$time_iso8601, time in ISO 8601 format, e. g. 2011-03-21T18:52:25+03:00 (added in 0.9.6)

$time_local, local time into common log format.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.