{"id":3857,"date":"2019-02-13T11:38:59","date_gmt":"2019-02-13T03:38:59","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3857"},"modified":"2019-02-13T11:38:59","modified_gmt":"2019-02-13T03:38:59","slug":"nginx-%e7%9a%84-access_log-%e6%8c%87%e4%bb%a4%e5%bc%80%e5%90%af%e9%85%8d%e7%bd%ae%e8%87%aa%e5%ae%9a%e4%b9%89%e6%97%a5%e5%bf%97%e6%95%99%e7%a8%8b%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3857","title":{"rendered":"Nginx \u7684 access_log \u6307\u4ee4\u5f00\u542f\u914d\u7f6e\u81ea\u5b9a\u4e49\u65e5\u5fd7\u6559\u7a0b\uff01"},"content":{"rendered":"<p>\n\t\u65e5\u5fd7\u5c31\u76f8\u5f53\u4e8e\u8f6f\u4ef6\u7cfb\u7edf\u7684\u9ed1\u5323\u5b50\uff01\u6ca1\u6709\u5b83\uff0c\u7b80\u76f4\u5c31\u662f\u707e\u96be\uff01\n<\/p>\n<p>\n\t\u4f60\u4e5f\u5f88\u96be\u8bb2\u6e05\u695a\uff0c\u529f\u80fd\u548c\u65e5\u5fd7\u54ea\u4e2a\u66f4\u91cd\u8981\u3002\u529f\u80fd\u670d\u52a1\u4e8e\u5ba2\u6237\uff0c\u7528\u6237\u7b49\u4f7f\u7528\u8005\uff0c\u65e5\u5fd7\u670d\u52a1\u4e8e\u6211\u4eec\u81ea\u5df1\uff0c\u65b9\u4fbf\u6211\u4eec\u6392\u67e5\u95ee\u9898\u3002\u6240\u4ee5\u6211\u4eec\u8981\u5199\u597d\u65e5\u5fd7\uff0c\u8bb0\u597d\u65e5\u5fd7\uff01\n<\/p>\n<p>\n\tNginx &nbsp;\u4e5f\u63d0\u4f9b\u4e86\u975e\u5e38\u5f3a\u5927\u7684\u65e5\u5fd7\u529f\u80fd\u3002\u6bd4\u5982\uff0c\u6211\u5728\u8fd9\u7bc7\u300a<a href=\"https:\/\/www.xttblog.com\/?p=3570\">\u6628\u5929\uff0c\u6211\u548c\u9ed1\u5ba2\u4e4b\u95f4\u7684\u4e00\u6b21\u653b\u9632\u6f14\u7ec3\uff01<\/a>\u300b\u4e0e\u9ed1\u5ba2\u73a9\u6349\u732b\u732b\u7684\u6e38\u620f\u4e2d\u5c31\u7528\u5230\u4e86&nbsp;Nginx \u7684 access_log \u65e5\u5fd7\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u6ca1\u6709\u65e5\u5fd7\u600e\u4e48\u89e3\u51b3 BUG\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g04mp3vp1zj20fz08faaw.jpg\" style=\"width: 575px;height: 303px\" \/>\n<\/p>\n<p>\n\t\u5728 Nginx \u4e2d\uff0caccess_log \u6307\u4ee4\u4e5f\u5b58\u5728\u4e8e ngx_http_log_module \u6a21\u5757\u4e2d\u3002\n<\/p>\n<p>\n\t\u5982\u679c\u4f60\u672a\u914d\u7f6e\uff0caccess_log \u65e5\u5fd7\u4e5f\u662f\u9ed8\u8ba4\u5f00\u542f\u7684\u3002access_log \u7684\u9ed8\u8ba4\u503c\u5982\u4e0b\u6240\u793a\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\naccess_log log\/access.log combined<\/pre>\n<h2>\n\taccess_log \u6307\u4ee4<br \/>\n<\/h2>\n<p>\n\taccess_log \u6307\u4ee4\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\naccess_log path [format [buffer=size [flush=time]]];\r\naccess_log path format gzip[=level] [buffer=size] [flush=time];\r\naccess_log syslog:server=address[,parameter=value] [format];\r\naccess_log off;<\/pre>\n<p>\n\taccess_log \u6307\u4ee4\u7684\u914d\u7f6e\u6bb5\u652f\u6301: http, server, location, if in location, limit_except\u3002\n<\/p>\n<p>\n\t\u5176\u4e2d access_log off; \u4ee3\u8868\u5173\u95ed\u65e5\u5fd7\u3002\u901a\u5e38\u6211\u4e0d\u5efa\u8bae\u8fd9\u4e48\u505a\uff01\n<\/p>\n<p>\n\tgzip \u662f\u538b\u7f29\u7b49\u7ea7\uff1bbuffer \u53ef\u4ee5\u8bbe\u7f6e\u5185\u5b58\u7f13\u5b58\u533a\u7684\u5927\u5c0f\uff1bflush \u662f\u4fdd\u5b58\u5728\u7f13\u5b58\u533a\u4e2d\u7684\u6700\u957f\u65f6\u95f4\uff1bcombined \u662f\u4e00\u79cd\u9ed8\u8ba4\u7684\u65e5\u5fd7\u683c\u5f0f\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u6ca1\u6709\u65e5\u5fd7\u7684\u7cfb\u7edf\u5c31\u662f\u5728\u88f8\u5954\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g04n6ptvs7j20bz077wgx.jpg\" style=\"width: 431px;height: 259px\" \/>\n<\/p>\n<p>\n\t\u4e0b\u9762\u662f\u6211\u7684\u4e00\u4e2a\u914d\u7f6e\u6848\u4f8b\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\nhttp {\r\n  #access\u65e5\u5fd7\u683c\u5f0f\u914d\u7f6e\uff0c\u5177\u4f53\u53c2\u6570\u4e0d\u518d\u7ec6\u8bf4\uff0c\u4e0a\u9762\u90fd\u5df2\u7ecf\u8bf4\u8fc7\u4e86\uff0c\u81ea\u5df1\u5bf9\u5e94\u4e00\u4e0b\u5373\u53ef\r\n  log_format main &#039;$remote_addr - $remote_user [$time_local] &#039;\r\n     &#039;fwf[$http_x_forwarded_for] tip[$http_true_client_ip] &#039;\r\n     &#039;$upstream_addr $upstream_response_time $request_time &#039;\r\n     &#039;$geoip_country_code &#039;\r\n     &#039;$http_host $request &#039;\r\n     &#039;&quot;$status&quot; $body_bytes_sent &quot;$http_referer&quot; &#039;\r\n     &#039;&quot;$http_accept_language&quot; &quot;$http_user_agent&quot; &#039;;\r\n\r\n  server {\r\n    server_name ~^(www\\.)?(.+)$;\r\n    access_log logs\/$2-access.log main;\r\n    error_log logs\/$2-error.log;\r\n    location \/srcache {\r\n      #\u914d\u7f6eaccess log\u65e5\u5fd7\u7684\u5b58\u50a8\u4f4d\u7f6e\u53ca\u6587\u4ef6\uff0c\u6ce8\u610f\uff1aaccess.log\u6587\u4ef6\u662f\u53ef\u4ee5\u6309\u65e5\u671f\u8fdb\u884c\u5206\u5272\u7684\uff0c\u65b9\u4fbf\u67e5\u770b\u53ca\u5904\u7406\r\n      access_log  \/home\/serversoft\/nginx\/log\/access.log  main;\r\n    }\r\n  }\r\n}<\/pre>\n<p>\n\t\u9700\u8981\u6ce8\u610f\u7684\u662f&nbsp;access_log \u5df2\u5f00\u542f\uff0c\u4f1a\u975e\u5e38\u7684\u5927\u3002\u6700\u7ec8\u4f60\u67e5\u770b\uff0c\u4f7f\u7528\u53ef\u80fd\u4e0d\u65b9\u4fbf\u3002\u8fd9\u65f6\u6211\u63a8\u8350\u4f60\u770b\u6211\u7684\u8fd9\u7bc7\u6587\u7ae0\u300a<a href=\"https:\/\/www.xttblog.com\/?p=3718\">\u8be6\u89e3 nginx\u65e5\u5fd7\u5206\u5272\u548c nginx \u65e5\u5fd7\u5b89\u5168\u5206\u5272<\/a>\u300b\uff0c\u628a Nginx \u7684\u65e5\u5fd7\u8fdb\u884c\u5206\u5272\u3002\n<\/p>\n<p>\n\t\u66f4\u591a\u5173\u4e8e access_log(\u8bbf\u95ee\u65e5\u5fd7)\u3001log_format\uff08\u65e5\u5fd7\u683c\u5f0f\uff09\u3001open_log_file_cache\u3001log_not_found\u3001log_subrequest\u3001rewrite_log\u3001error_log \u7b49\u6307\u4ee4\u7684\u6559\u7a0b\uff0c\u8bf7\u5173\u6ce8\u6211\u7684\u535a\u5ba2\u6216\u516c\u4f17\u53f7\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3857\">Nginx \u7684 access_log \u6307\u4ee4\u5f00\u542f\u914d\u7f6e\u81ea\u5b9a\u4e49\u65e5\u5fd7\u6559\u7a0b\uff01<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u65e5\u5fd7\u5c31\u76f8\u5f53\u4e8e\u8f6f\u4ef6\u7cfb\u7edf\u7684\u9ed1\u5323\u5b50\uff01\u6ca1\u6709\u5b83\uff0c\u7b80\u76f4\u5c31\u662f\u707e\u96be\uff01 \u4f60\u4e5f\u5f88\u96be\u8bb2\u6e05\u695a\uff0c\u529f\u80fd\u548c\u65e5\u5fd7\u54ea\u4e2a\u66f4\u91cd\u8981\u3002\u529f\u80fd\u670d\u52a1\u4e8e\u5ba2\u6237\uff0c\u7528 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118,6],"tags":[1827,1152,313,1154,239],"class_list":["post-3857","post","type-post","status-publish","format-standard","hentry","category-ndisdevelop","category-yyzt","tag-access_log","tag-nginx","tag-nginx-tfs","tag-tomcat"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3857"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3857\/revisions"}],"predecessor-version":[{"id":3858,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3857\/revisions\/3858"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}