一,前言
1,进入nginx的配置文件
cd /etc/nginx 不同机器可能会有不同
2,nginx的默认日志配置文件
3,注释掉,切换为自己需要的json格式(1.11.8版本开始支持)
json_log escape=json '{"realip":"$remote_addr","@timestamp":"$time_iso8601","host":"$http_host","request":"$request","req_body":"$request_body","status":"$status","size":$body_bytes_sent,"ua":"$http_user_agent","cookie":"$http_cookie","req_time":"$request_time","uri":"$uri","referer":"$http_referer","xff":"$http_x_forwarded_for","ups_status":"$upstream_status","ups_addr":"$upstream_addr","ups_time":"$upstream_response_time"}';
一,分析
1,查看nginx的日志写入路径
2,进入对应目录
cd /data2/logs/nginx/aitefudao/
3,用cat命令或者tac命令分析nginx日志
tac access.log | head -n 10