Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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

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

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
add comment

Your Answer

 
discard

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.