nginx日志參數及含義


參數含義

$remote_addr,$http_x_forwarded_for  #記錄客戶端IP地址
$remote_user   #記錄客戶端用戶名稱
$request       #記錄請求的URL和HTTP協議
$status        #記錄請求狀態
$body_bytes_sent  #發送給客戶端的字節數,不包括響應頭的大小;該變量與Apache模塊mod_log_config李的“%B”參數兼容
$bytes_sent    #發送給客戶端的總字節數
$connection    #連接到序列號
$connection_requests #當前通過一個鏈接獲得的請求數量
$msec       #日志寫入時間,單位為秒精度是毫秒。
$pipe       #如果請求是通過HTTP流水線(pipelined)發送,pipe值為“p”,否則為".".
$http_referer  #記錄從那個頁面鏈接訪問過來的
$http_user_agent  #記錄客戶端瀏覽器相關信息
$request_length   #請求的長度(包括請求行,請求頭和請求正文)。
$request_time #請求處理時間,單位為秒,精度毫秒;從讀入客戶端的第一個字節開始,知道把最后一個字符發送給客戶端后進行日志寫入位置。
$time_iso8601 ISO8601標准格式下的本地時間
$time_local  #通用日志格式下的本地時間

原生格式

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
	          '$status $body_bytes_sent $bytes_sent $request_length "$http_referer" '
	          '"$http_user_agent" $http_x_forwarded_for '
	          '"$upstream_addr" "$upstream_status" "$upstream_response_time" "$request_time"';

改造成json格式

log_format main '{"@timestamp": "$time_local", '
                '"remote_addr": "$remote_addr", '
                '"referer": "$http_referer", '
                '"request": "$request", '
                '"status": $status, '
                '"bytes": $body_bytes_sent, '
                '"agent": "$http_user_agent", '
                '"upstream_addr": "$upstream_addr",'
                '"upstream_status": "$upstream_status",'
                '"up_resp_time": "$upstream_response_time",'
                '"request_time": "$request_time"'
                ' }';


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM