如果我们不需要,在http段中加一行access_log off;然后在特定的server中配置自己想写入的日志。开发环境我默认不写日志,即不配置任何access_log,需要时才打开。
nginx的http段中,设置access log:
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; log_format gzip '$remote_addr - $remote_user [$time_local] "$request" ' '$status $bytes_sent "$http_referer" ' '"$http_user_agent" "$gzip_ratio"'; log_format download '$remote_addr - $remote_user [$time_local] "$request" ' '$status $bytes_sent "$http_referer" "$http_user_agent" ' '"$http_range" "$sent_http_content_range"'; #access_log logs/access.log main; access_log off;