log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main;
默認值:log_format combined "...";
html
標籤段位置:http
nginx
經常使用變量:瀏覽器
若是變量對應的值不存在,則以「
-
」代替。
默認值:access_log logs/access.log combined;
日誌
標籤段位置:http
, server
, location
, if in location
, limit_except
code
access_log off; access_log logs/access.log main; access_log logs/access.log main buffer=32k flush=5s;
map $status $loggable { ~^[23] 0; default 1; } # 非2xx 和 3xx 的狀態才寫入日誌 access_log /path/to/access.log main if=$loggable;
../sbin/nginx -t ../sbin/nginx -s reload