时间:2021-07-01 10:21:17 帮助过:12人阅读
access_log /data/logs/nginx-access.log;log_format old '$remote_addr [$time_local] $status $request_time $body_bytes_sent ''"$request" "$http_referer" "$http_user_agent"';
access_log /data/logs/nginx-access.log buffer=32k flush=5s;
log_format new '$remote_addr^A$http_x_forwarded_for^A$host^A$time_local^A$status^A''$request_time^A$request_length^A$bytes_sent^A$http_referer^A$request^A$http_user_agent';
cat access.log | awk -F ‘^A’ ‘{print $10}’ | sort | uniq -c
cat access.log | awk -F ‘^A’ ‘{if($5 == 500) print $0}’
cat access.log | awk -F ‘^A’ ‘{if($5 == 500) print $0}’ | wc -l
cat access.log | awk -F ‘^A’ ‘{if($5 == 500) print $0}’ | grep ’09:00’ | wc-l
tail -f access.log | awk -F ‘^A’ ‘{if($6>1) print $0}’
tail -f access.log | awk -F ‘^A’ ‘{if($6>1) print $3″|”$4}’
cat access.log | awk -F ‘^A’ ‘{if($5==502) print $11}’ | sort | uniq -c
cat access.log | awk -F ‘^A’ ‘{if($5==200 && $8 < 100) print $3″|”$4″|”$11″|”$6}’
tail -f access.log | cat -e
或者
tail -f access.log | tr ‘^A’ ‘|’
以上就介绍了纯手工玩转 Nginx 日志,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。