Apache和Nginx的日志格式比较
对比Apache和Nginx的日志格式。
ApacheNginxDescription説明%a$remote_addrRemote IP addressリモート IP アドレス%A$server_addrServer IP addressローカル IP アドレス%B$body_bytes_sentBytes sentレスポンスのバイト数 HTTP ヘッダは除く%b$body_bytes_sentBytes sent (0 = ‘-‘)レスポンスのバイト数。HTTP ヘッダは除く CLF 書式 0のときは-(ハイフン)になる%D-processing time[microsec]リクエストを処理するのにかかった時間、マイクロ秒単位%f$request_filenameRequested File pathリクエストされたファイル名%h-Remote Hostリモートホスト名%H$server_protocolRequest protocolリクエストプロトコル名%K-KeepAlive Connectionkeepaliveのコネクション数%l-Remote Log Nameリモートログ名%m$request_methodRequest Method”リクエストメソッド(GET%p$server_portServer Portリクエストを受けたポート番号%P$pidProcess ID子プロセスID%q$query_stringQuery String e.g.http://example.com/test.php?id=12345 -> ?id=12345クエリ文字列%r$request”First Line of Requestリクエストの最初の行 基本的には%m %U$q %Hとした内容と同じ%s$statusStatus Codeステータスコード%t$time_localRequest Time[11/Aug/2017:12:34:56 +0900]リクエストを受け付けた日時%{format}t-Request Time with custom format (refer: strftime(3)format で与えられた書式による時刻%T$request_timeProccessing Timeリクエストを受けてから応答するまでの処理時間[秒] %Dの秒数版 Nginxはミリ秒まで%u$remote_userRemote userリモートユーザ%U$request_uriRequest Pathリクエストされたパス%v$server_nameServer nameサーバーのServerName%V$server_nameServer name(UseCanonicalName)UseCanonicalNameで指定されたサーバー名%X$request_completionConnection status X=aborted + = kept alive – = closed応答が完了したときの接続ステータス%I$request_lengthBytes received including request and headersリクエストとヘッダを含む受け取ったバイト数%O$bytes_sentBytes sent including headersヘッダを含むサーバーから送信されたバイト数%{Referer}i$http_refererRefererリファラー%{User-Agent}i$http_user_agentUser Agentエージェント
只有Nginx
FormatDescription$argsarguments in the request line$binary_remote_addr$remote_addrのバイナリ版$connectionconnection serial number$connection_requestscurrent number of requests made through a connection$content_length“Content-Length” request header field$content_type“Content-Type” request header field$document_rootroot or alias directive’s value for the current request$document_urisame as $uri$hostServer Host$hostnamehost name$https“on” if connection operates in SSL mode, or an empty string otherwise$limit_ratesetting this variable enables response rate limiting$mseccurrent time in seconds with the milliseconds resolution$nginx_versionnginx version$pipe“p” if request was pipelined, “.” otherwise$proxy_protocol_addrclient address from the PROXY protocol header, or an empty string otherwise$realpath_root$document_rootのリアルパス$remote_portクライアントのポート$request_bodyrequest body$request_body_filename of a temporary file with the request body$schemehttp$sent_http_namearbitrary response header field$time_iso8601local time in the ISO 8601 standard format
参考链接:
楪総研第三分室
Apache日志格式
Nginx日志变量