ngx_http_log_module 实例
log_format gzip '$remote_addr - $remote_user [$time_local] '
: '"$request" $status $bytes_sent '
: '"$http_referer" "$http_user_agent" "$gzip_ratio"';
access_log /spool/logs/nginx-access.log gzip buffer=32k;
语法:*access_log path [format [buffer=size | off ] 默认值:access_log log/access.log combined*
作用域:*http, server, location*
指令 access_log 指派路径、格式和缓存大小。参数 "off" 将清除当前级别的所有 access_log 指令。如果未指定格式,则使用预置的 "combined" 格式。缓存不能大于能写入磁盘的文件的最大大小。在 FreeBSD 3.0-6.0 ,缓存大小无此限制。
语法:*log_format name format [format ...]*
默认值:*log_format combined "..."*
作用域:*http*server
Directive log_format describes the format of a log entry. Besides general variables in the format it is possible to use variables which exist only at the moment of record into the log:
The headers, transmitted to client, begin from the prefix "senthttp", for example, $sent_http_content_range.
In the configuration there is always a predetermined format "combined":
log_format combined '$remote_addr - $remote_user [$time_local] '
: '"$request" $status $apache_bytes_sent '
: '"$http_referer" "$http_user_agent"';