Nginx是最经常使用的web服务器,其能够承受的并发访问量远远大于apache,经过将nginx保存为json格式,而后对日志进行分析展现,可以获取到不少更直观的信息,而后加以统计,能够进行更多的数据展现。html
log_format access_json '{"@timestamp":"$time_iso8601",' '"host":"$server_addr",' '"clientip":"$remote_addr",' '"size":$body_bytes_sent,' '"responsetime":$request_time,' '"upstreamtime":"$upstream_response_time",' '"upstreamhost":"$upstream_addr",' '"http_host":"$host",' '"uri":"$uri",' '"domain":"$host",' '"xff":"$http_x_forwarded_for",' '"referer":"$http_referer",' '"tcp_xff":"$proxy_protocol_addr",' '"http_user_agent":"$http_user_agent",' '"status":"$status"}'; access_log logs/access.log access_json;
[root@CentOS7-1 ~]#/apps/nginx/sbin/nginx -s reload [root@CentOS7-1 ~]#tail -f /apps/nginx/logs/*.log {"@timestamp":"2019-06-04T15:40:15+08:00","host":"192.168.36.110","clientip":"192.168.36.104","size":0,"responsetime":0.000,"upstreamtime":"-","upstreamhost":"-","http_host":"192.168.36.104","uri":"/index.html","domain":"192.168.36.104","xff":"192.168.36.1","referer":"-","tcp_xff":"","http_user_agent":"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:67.0) Gecko/20100101 Firefox/67.0","status":"304"}