FAQ

Page Discussion Edit History

RuHttpLogModule

(Redirected from NginxRuHttpLogModule)

Contents

[edit] ngx_http_log_module

袦芯写褍谢褜 ngx_http_log_module 蟹邪锌懈褋褘胁邪械褌 谢芯谐懈 蟹邪锌褉芯褋芯胁 胁 褍泻邪蟹邪薪薪芯屑 褎芯褉屑邪褌械. 小芯写械褉卸邪薪懈械 袩褉懈屑械褉 泻芯薪褎懈谐褍褉邪褑懈懈


[edit] 袛懈褉械泻褌懈胁褘

  • [#access_log access_log]
  • [#log_format log_format ]

袩褉懈屑械褉 泻芯薪褎懈谐褍褉邪褑懈懈

: log_format  gzip  '$remote_addr - $remote_user [$time_local]  '
: '"$request" $status $bytes_sent '
: '"$http_referer" "$http_user_agent" "$gzip_ratio"';

: access_log  /spool/logs/nginx-access.log  gzip  buffer=32k;


Template:Anchor

[edit] access_log

syntax: access_log 锌褍褌褜 [褎芯褉屑邪褌 [buffer=褉邪蟹屑械褉 |off ] default: access_log log/access.log combined

context: http, server, location

袛懈褉械泻褌懈胁邪 access_log 蟹邪写邪褢褌 锌褍褌褜, 褎芯褉屑邪褌 懈 褉邪蟹屑械褉 斜褍褎械褉邪 写谢褟 斜褍褎械褉懈蟹懈褉芯胁邪薪薪芯泄 蟹邪锌懈褋懈 胁 谢芯谐. 袧邪 芯写薪芯屑 褍褉芯胁薪械 屑芯卸械褌 懈褋锌芯谢褜蟹芯胁邪褌褜褋褟 薪械褋泻芯谢褜泻芯 谢芯谐芯胁. 袩邪褉邪屑械褌褉 "off" 芯褌屑械薪褟械褌 胁褋械 写懈褉械泻褌懈胁褘 access_log 写谢褟 褌械泻褍褖械谐芯 褍褉芯胁薪褟. 袝褋谢懈 褎芯褉屑邪褌 薪械 褍泻邪蟹邪薪, 褌芯 懈褋锌芯谢褜蟹褍械褌褋褟 锌褉械写芯锌褉械写械谢褢薪薪褘泄 褎芯褉屑邪褌 "combined".

袪邪蟹屑械褉 斜褍褎械褉邪 写芯谢卸械薪 斜褘褌褜 薪械 斜芯谢褜褕械 褉邪蟹屑械褉邪 邪褌芯屑邪褉薪芯泄 蟹邪锌懈褋懈 胁 写懈褋泻芯胁褘泄 褎邪泄谢. 袛谢褟 FreeBSD 3.0-6.0 褝褌芯褌 褉邪蟹屑械褉 薪械芯谐褉邪薪懈褔械薪.


Template:Anchor

[edit] log_format

syntax: log_format 薪邪蟹胁邪薪懈械 褋褌褉芯泻邪 [褋褌褉芯泻邪 ...]

default: log_format combined "..."

context: http

袛懈褉械泻褌懈胁邪 log_format 芯锌懈褋褘胁邪械褌 褎芯褉屑邪褌 谢芯谐邪.

袣褉芯屑械 芯斜褖懈褏 锌械褉械屑械薪薪褘褏 胁 褎芯褉屑邪褌械 屑芯卸薪芯 懈褋锌芯谢褜蟹芯胁邪褌褜 锌械褉械屑械薪薪褘械, 褋褍褖械褋褌胁褍褞褖懈械 褌芯谢褜泻芯 薪邪 屑芯屑械薪褌 蟹邪锌懈褋懈 胁 谢芯谐:

  • $body_bytes_sent, 褔懈褋谢芯 斜邪泄褌, 锌械褉械写邪薪薪芯械 泻谢懈械薪褌褍 蟹邪 胁褘褔械褌芯屑 蟹邪谐芯谢芯胁泻邪 芯褌胁械褌邪, 锌械褉械屑械薪薪邪褟 褋芯胁屑械褋褌懈屑邪 褋 锌邪褉邪屑械褌褉芯屑 %B 屑芯写褍谢褟 Apache mod_log_config;
  • $bytes_sent, 褔懈褋谢芯 斜邪泄褌, 锌械褉械写邪薪薪芯械 泻谢懈械薪褌褍;
  • $connection, 薪芯屑械褉 褋芯械写懈薪械薪懈褟;
  • $msec, 胁褉械屑褟 褋 褌芯褔薪芯褋褌褜褞 写芯 屑懈泻褉芯褋械泻褍薪写 薪邪 屑芯屑械薪褌 蟹邪锌懈褋懈 胁 谢芯谐;
  • $pipe, "p" 械褋谢懈 蟹邪锌褉芯褋 斜褘谢 pipeling ;
  • $request_length, 写谢懈薪邪 褌械谢邪 蟹邪锌褉芯褋邪;
  • $request_time, 胁褉械屑褟 芯斜褉邪斜芯褌泻懈 蟹邪锌褉芯褋邪 胁 褋械泻褍薪写邪褏;
  • $status, 褋褌邪褌褍褋 芯褌胁械褌邪;
  • $time_local, 谢芯泻邪谢褜薪芯械 胁褉械屑褟 胁 common log format.

小褌褉芯泻懈 蟹邪谐芯谢芯胁泻邪, 锌械褉械写邪薪薪褘械 泻谢懈械薪褌褍, 薪邪褔懈薪邪褞褌褋褟 褋 锌褉械褎懈泻褋邪 "sent_http_", 薪邪锌褉懈屑械褉, $sent_http_content_range.

袙 泻芯薪褎懈谐褍褉邪褑懈懈 胁褋械谐写邪 褋褍褖械褋褌胁褍械褌 锌褉械写芯锌褉械写械谢褢薪薪褘泄 褎芯褉屑邪褌 "combined":

: log_format  combined  '$remote_addr - $remote_user [$time_local]  '
: '"$request" $status $apache_bytes_sent '
: '"$http_referer" "$http_user_agent"';