Nginx中日志文件的格式在nginx.conf中定义,其默认格式如下:
log_format main '$remote_addr -
r
e
m
o
t
e
u
s
e
r
[
remote_user [
remoteuser[time_local] " KaTeX parse error: Double superscript at position 33: … '̲status
b
o
d
y
b
y
t
e
s
s
e
n
t
"
body_bytes_sent "
bodybytessent"http_referer" ’
'“
h
t
t
p
u
s
e
r
a
g
e
n
t
"
"
http_user_agent" "
httpuseragent""http_x_forwarded_for”;
access_log /usr/local/nginx/var/log/access.log main ;
参数具体含义如下:
r e m o t e a d d r : 与 remote_addr :与 remoteaddr:与http_x_forwarded_for用以记录客户端的ip地址;
$remote_user :记录客户端用户的名称;
$time_local :访问时间及时区;
$request :请求的URL与HTTP协议;
$status :记录请求状态
$body_bytes_sent:记录发送给客户端文件主体内容大小;
$http_referer:用来记录从那个页面链接访问过来的;
$http_user_agent:记录客户端浏览器的相关信息
access_log /usr/local/nginx/var/log/access.log main ; 这句话是日志文件存放的位置
这里是默认的配置,但是有的时候我们需要自己配置我们的nginx日志格式,下面给出一些常用的参数配置。
$bytes_sent :客户端发送的字节数
$request_length:客户端请求的长度
$http_host :客户端请求的地址请求地址,即浏览器中你输入的地址(IP或域名)
$upstream_status:upstream状态
$upstream_addr :后台upstream的地址,即真正提供服务的主机地址
$request_time : 整个请求的总时间
$upstream_response_time:请求过程中,upstream响应时间
$request_body :POST数据
转载