nginx之日誌配置
阿新 • • 發佈:2018-12-07
nginx.conf檔案配置:
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
#日誌生成的到Nginx根目錄/var/log/nginx/access.log檔案,預設使用“main”日誌格式,也可以自定義格式。
引數明細表:
$remote_addr |
客戶端的ip地址(代理伺服器,顯示代理服務ip) |
$remote_user |
用於記錄遠端客戶端的使用者名稱稱(一般為“-”) |
$time_local |
用於記錄訪問時間和時區 |
$request |
用於記錄請求的url以及請求方法 |
$status |
響應狀態碼,例如:200成功、404頁面找不到等。 |
$body_bytes_sent |
給客戶端傳送的檔案主體內容位元組數 |
$http_user_agent |
使用者所使用的代理(一般為瀏覽器) |
$http_x_forwarded_for |
可以記錄客戶端IP,通過代理伺服器來記錄客戶端的ip地址 |
$http_referer |
可以記錄使用者是從哪個連結訪問過來的 |