2017年02月17日 20:48:10nginx
閱讀數:41757apache
前言瀏覽器
前邊介紹了apache服務器下的訪問日誌與錯誤日誌的介紹查看與簡單的分析服務器
那麼本篇介紹一下在nginx服務器的的兩種日誌的查看。ide
查找日誌存放地址url
find / -name nginx.conf
根據你找出來的地址,盡心vi編輯,進入nginx.conf文件進行查找路徑spa
vi /usr/servers/nginx/conf/nginx.conf
從而找到,我機子的兩個日誌存放地點:.net
/var/logdata/nginx/access.log3d
/var/logdata/nginx/error.log日誌
查看access訪問日誌
vi /var/logdata/nginx/access.log
訪問日誌分析
摘出來一段部分結果:
100.109.195.91 - - [17/Feb/2017:00:08:11 +0800] "GET /data/upload/shop/common/loading.gif HTTP/1.0" 200 134 "http://www.mall121.com/" "Mozilla/4.0 (compatible; MSIE 8.0; Trident/4.0; Windows NT 6.1; SLCC2 2.5.5231; .NET CLR 2.0.50727; .NET CLR 4.1.23457; .NET CLR 4.0.23457; Media Center PC 6.0; MS-WK 8)" "140.205.201.12"
100.109.195.78 - - [17/Feb/2017:00:08:11 +0800] "GET /shop/templates/default/images/u-safe.png HTTP/1.0" 200 3675 "http://www.mall121.com/" "Mozilla/4.0 (compatible; MSIE 8.0; Trident/4.0; Windows NT 6.1; SLCC2 2.5.5231; .NET CLR 2.0.50727; .NET CLR 4.1.23457; .NET CLR 4.0.23457; Media Center PC 6.0; MS-WK 8)" "140.205.201.12"
100.109.195.26 - - [17/Feb/2017:00:08:11 +0800] "GET /data/upload/shop/adv/05240495346955824.jpg HTTP/1.0" 404 564 "http://www.mall121.com/" "Mozilla/4.0 (compatible; MSIE 8.0; Trident/4.0; Windows NT 6.1; SLCC2 2.5.5231; .NET CLR 2.0.50727; .NET CLR 4.1.23457; .NET CLR 4.0.23457; Media Center PC 6.0; MS-WK 8)" "140.205.201.12"
1.100.109.195.91 :
$remote_addr : 客戶端(用戶)IP地址
2.[17/Feb/2017:00:08:11 +0800]:
$time_local :訪問時間
3."GET /data/upload/shop/common/loading.gif HTTP/1.0" :
"$request"get請求的url地址(目標url地址)的host
4.200:
'$status請求狀態(狀態碼,200表示成功,404表示頁面不存在,301表示永久重定向等,具體狀態碼能夠在網上找相關文章,再也不贅述)
5. 134 :
$body_bytes_sent :請求頁面大小,默認爲B(byte
6."http://www.mall121.com/" :
"$http_referer" : 來源頁面,即從哪一個頁面轉到本頁,專業名稱叫作「referer」
7."Mozilla/4.0 (compatible; MSIE 8.0; Trident/4.0; Windows NT 6.1; SLCC2 2.5.5231; .NET CLR 2.0.50727; .NET CLR 4.1.23457; .NET CLR 4.0.23457; Media Center PC 6.0; MS-WK 8)":
$http_user_agent:用戶瀏覽器其餘信息,瀏覽器版本、瀏覽器類型
8. "140.205.201.12" :
$http_x_forwarded_for"
或者經過nginx配置文件裏的配置,換一種格式:
log_format main '$remote_addr - $remote_user [$time_local] '
'fwf[$http_x_forwarded_for] tip[$http_true_client_ip] '
'$upstream_addr $upstream_response_time $request_time '
'$geoip_country_code '
'$http_host $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_accept_language" "$http_user_agent" ';
1.客戶端(用戶)IP地址。
2.訪問時間。
3.訪問端口。
4.響應時間。
5.請求時間。
6.用戶地理位置代碼(國家代碼)。
7.請求的url地址(目標url地址)的host。
8.請求方式(GET或者POST等)。
9.請求url地址(去除host部分)。
10.請求狀態(狀態碼,200表示成功)。
11.請求頁面大小,默認爲B(byte)。
12.來源頁面,即從哪一個頁面轉到本頁,專業名稱叫作「referer」。
13.用戶瀏覽器語言。如:上例中的 "es-ES,es;q=0.8"
14.用戶瀏覽器其餘信息,瀏覽器版本、瀏覽器類型等。
錯誤日誌同理,
vi /var/logdata/nginx/error.log
關於錯誤日誌的查看,這裏就很少贅述。