Maison >développement back-end >tutoriel php >纯手工玩转 Nginx 日志
access_log <span>/</span>data<span>/</span>logs<span>/</span>nginx<span>-</span>access<span>.</span><span>log</span><span>;</span>log_format old <span><em>'$remote_addr [$time_local] $status $request_time $body_bytes_sent '</em></span><span><em>'"$request" "$http_referer" "$http_user_agent"'</em></span><span>;</span>
access_log <span>/</span>data<span>/</span>logs<span>/</span>nginx<span>-</span>access<span>.</span><span>log</span> buffer<span>=</span><span><em>32k</em></span> flush<span>=</span><span><em>5s</em></span><span>;</span>
log_format new <span><em>'$remote_addr^A$http_x_forwarded_for^A$host^A$time_local^A$status^A'</em></span><span><em>'$request_time^A$request_length^A$bytes_sent^A$http_referer^A$request^A$http_user_agent'</em></span><span>;</span>
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
tail -f access.log | cat -e
或者
tail -f access.log | tr ‘^A’ ‘|’
以上就介绍了纯手工玩转 Nginx 日志,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。