默认的 nginx 日志格式:
- log_format access '$remote_addr - $remote_user [$time_local]"$request"''$status $body_bytes_sent "$http_referer" ''"$http_user_agent""$http_x_forwarded_for"';
- access_log /usr/local/nginx/logs/access.log access;
1 更改默认 nginx 日志格式 部分配置文件如下
- #vim /usr/local/nginx/conf/nginx.conf
- log_format access '$remote_addr - $remote_user[$time_local]"$request"''$status $body_bytes_sent "$http_referer" ''" $http_user_agent""$http_x_forwarded_for"'
- '"$upstream_cache_status" "$upstream_addr" "$request_time" $upstream_response_time $http_host';
- access_log /usr/local/nginx/logs/access.log access;
- }
- include /usr/local/nginx/conf/vhost/*.conf; # 这个是包括虚拟主机的目录
2 日志格式说明
$remote_addr 与 $http_x_forwarded_for 用以记录客户端的 ip 地址;
$remote_user : 用来记录客户端用户名称;
$time_local : 用来记录访问时间与时区;
$request : 用来记录请求的 url 与 http 协议;
$status : 用来记录请求状态; 成功是 200,
$body_bytes_sent : 记录发送给客户端文件主体内容大小;
$http_referer : 用来记录从那个页面链接访问过来的;
$http_user_agent : 记录客户端浏览器的相关信息;
$http_host : 请求地址, 即浏览器中你输入的地址 (IP 或域名)
$upstream_status upstream 状态 成功是 200
$body_bytes_sent 发送给客户端文件内容大小
$ssl_protocol SSL 协议版本
$ssl_cipher 交换数据中的算法
$upstream_addr 后台 upstream 的地址, 即真正提供服务的主机地址
$request_time 整个请求的总时间
$upstream_response_time 请求过程中, upstream 响应时间
来源: http://www.bubuko.com/infodetail-2538225.html