5

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...

7

I would use these 2 parameters in nginx.conf:

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

According to documentation ( http://wiki.nginx.org/HttpLogModule) 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).

| improve this answer | |
11

Taken from ngx_http_log_module:

$bytes_sent: the number of bytes sent to a client

$connection: connection serial number

$connection_requests: the current number of requests made through a connection (1.1.18)

$msec: time in seconds with a milliseconds resolution at the time of the log write

$pipe: “p” if request was pipelined, “.” otherwise

$request_length: request length (including request line, header, and request body)

$request_time: request processing time in seconds with a milliseconds resolution; time elapsed between the first bytes were read from the client and the log write after the last bytes were sent to the client

$status: response status

$time_iso8601: local time in the ISO 8601 standard format

$time_local: local time in the Common Log Format

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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