Logging Request/Response size in access_log of Nginx

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


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

Tags:

Nginx