nginx的access.log 和 error.log
nginx 常用的配置文件有两种: access.log 和 error.log access.log 的作用是 记录用户所有的访问请求,不论状态码,包括200 ,404,500等请求,404,500的请求并不会出现在error.log中。 error.log 的作用是 记录nginx 本身运行时的一些错误,不会记录用户访问的请求。比如记录模块错误信息日志,以及nginx配置文件的错误日志等,格式不支持自定义,可以设置级别。 access.log 的格式设置: log_format combined '$remote_addr - $remote_user [$time_local] ' ' "$request" $status $body_bytes_sent ' ' "$http_referer" "$http_user_agent" '; #日志格式允许包含的变量注释如下: $remote_addr, $http_x_forwarded_for 记录客户端IP地址 $remote_user 记录客户端用户名称 $request 记录请求的URL和HTTP协议 $status 记录请求状态 $body_bytes_sent 发送给客户端的字节数,不包括响应头的大小; 该变量与Apache模块mod_log_config里的“%B”参数兼容。 $bytes_sent