Nginx 一些内置的变量

core module var:
log module var:
$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 connections
$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 milliseconds, (in seconds for versions older than 0.5.19)
$status, status of answer
$time_local, local time into common log format.
$http_x_forwarded_for, X-Forward information 
# 于 apache 兼容的日志格式
------------------------------------------------- APACHE2.2 ------------------------------------------------
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %D %{TETX_USER_KEY}C" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
================================================== Nginx 0.7.35 ============================================
        log_format  tetx  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" 0 $request_time $TETX_USER_KEY "$http_x_forwarded_for" $host';
  1. mkfifo /path/to/nginx/logs/access_log_pipe
然后让 cronolog 从这个文件读:
  1. /path/to/cronolog /path/to/log/access_%Y%m%.log <  /path/to/nginx/logs/access_log_pipe &
把 nginx 的日志路径指到那个命名管道然后重启一下就可以了。之后在 nginx 的启动脚本里要把启动 cronolog 放在启动nginx 之前