如果我们不需要,在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;
本文探讨了Nginx服务器在未明确配置access_log时的行为,默认情况下它将所有server的访问日志写入到logs/access.log文件中。此外,介绍了如何通过配置禁用日志记录及自定义日志格式。

被折叠的 条评论
为什么被折叠?



