nginx 访问日志默认值
默认配置格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
=
0 日志内容展示
[root@uat-nginx-jenkins ~]# tail /var/log/nginx/admin.access.log
47.102.25.47 - - [17/Jul/2021:23:20:01 +0800] "POST /system/remote/site/public/community/syncSite?indexTime=1626534900020 HTTP/1.1" 200 5 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_192)"
47.102.25.47 - - [17/Jul/2021:23:20:01 +0800] "POST /system/remote/group/public/community/syncUserGroup?indexTime=1626534900020 HTTP/1.1" 200 5 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_192)"
47.102.25.49 - - [17/Jul/2021:23:20:01 +0800] "POST /system/remote/publicPlatformConfig/public/community/syncPlatformConfig?indexTime=1626534900020 HTTP/1.1" 404 158 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_192)"
...
=
1 remote_addr
- 表示发起访问的客户端 ip(一般为该用户的公网出口地址)
- 若客户端是代理访问,则默认为代理服务器的地址
- 若使用多层代理,则默认为最后一台代理服务器的地址
- 注:可以通过修改服务端配置实现
# 示例:
47.102.25.47
47.102.25.49
=
2 remote_user
- 启用用户验证()时所用的用户
- 一般不开启
# 示例:
- -
# 为什么是两个横线
因为第一个横线是格式中定义的普通字符
# 对应关系:
'$remote_addr - $remote_user [$time_local] ...
47.102.25.47 - - [17/Jul/2021:23:20:01 +0800] ...
=
3 [$time_local]
- 时间戳
# 示例:
[17/Jul/2021:23:20:01 +0800]
=
4 $request
# 示例:
"POST /system/remote/site/public/community/syncSite?indexTime=1626534900020 HTTP/1.1"
=
5 $status
# 示例:
200
404
502
=
6 $body_bytes_sent
# 示例:
5
236
345634
=
7 $http_referer
# 示例:
多为 "-" ,表示直接发起的访问
=
8 $http_user_agent
# 示例:
"Apache-HttpClient/4.5.12 (Java/1.8.0_192)"
=
9 $http_x_forwarded_for
=
wan