{"id":18653,"date":"2024-11-19T20:40:20","date_gmt":"2024-11-19T12:40:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=18653"},"modified":"2024-11-19T20:40:20","modified_gmt":"2024-11-19T12:40:20","slug":"haproxy%e4%b8%ad%e7%9a%84log%e7%9a%84%e7%9b%b8%e5%85%b3%e9%85%8d%e7%bd%ae%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18653\/","title":{"rendered":"Haproxy\u4e2d\u7684Log\u7684\u76f8\u5173\u914d\u7f6e\u8be6\u89e3"},"content":{"rendered":"<p>\u5728\u5b98\u65b9\u7684\u6587\u6863\u4e2d\uff1ahttp:\/\/cbonte.github.io\/haproxy-dconv\/1.7\/configuration.html#log<\/p>\n<p>\u5b9a\u4e49Log\u7684\u4f7f\u7528\u683c\u5f0f\uff1a<\/p>\n<pre><strong>log &lt;address&gt; [len &lt;length&gt;] [format &lt;format&gt;] &lt;facility&gt; [max level [min level]]\r\n#\u652f\u6301global\u3001defaults\u3001frontend\u3001backend\u3001listen\r\n<\/strong><\/pre>\n<h1><\/h1>\n<p><strong>Tips 1\uff1a<\/strong>log \u652f\u6301\u591a\u6761\uff0c\u5728\u914d\u7f6e\u4e2d\u53ef\u4ee5\u914d\u7f6e\u591a\u6761log\uff0c\u4f8b\u5982\u914d\u7f6eaccess\uff0cerror 2\u4e2a\u65e5\u5fd7.<\/p>\n<p><strong>Tips 2\uff1a<\/strong>\u65e5\u5fd7\u7684\u7ea7\u522b emerg\u00a0 alert\u00a0 crit\u00a0\u00a0 err\u00a0\u00a0\u00a0 warning notice info\u00a0 debug\uff0c\u51718\u4e2a<\/p>\n<p>\u4ece\u4f7f\u7528\u683c\u5f0f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230 &lt;address&gt; &lt;facility&gt;\u662f\u5fc5\u9009\u7684.<\/p>\n<h1>address\uff1a<\/h1>\n<p>\u652f\u6301IPv4\u3001IPv6\u3001socket\uff0c\u4e0d\u4e00\u5b9a\u662f\u672c\u5730\u7684IP<\/p>\n<h1>facility\uff1a<\/h1>\n<p>\u53c2\u8003\uff1aHaproxy\u4e2d\u7684log\u7684\u8bbe\u7f6e\u539f\u7406\u89e3\u6790<\/p>\n<h1>len\uff1a<\/h1>\n<p>\u65e5\u5fd7\u7684\u6700\u5927\u957f\u5ea6\uff0c\u5982\u679c\u5b9e\u9645\u65e5\u5fd7\u6d88\u606f\u5927\u4e8e\u8fd9\u4e2a\u503c\uff0c\u5c06\u88ab\u622a\u53d6\u540e\u53d1\u9001\u3002\u9ed8\u8ba4\u662f1024\uff0c\u8be5\u503c\u7684\u533a\u522b80 \u2013 65535\uff0c\u4e0d\u5728\u8fd9\u4e2a\u533a\u95f4\u5c06\u65e0\u6cd5\u542f\u52a8\u3002<\/p>\n<h1>format\uff1a<\/h1>\n<p>\u65e5\u5fd7\u683c\u5f0f\u89c4\u8303\uff0c\u53ef\u9009\u9879rfc3164\u3001rfc5424\uff0c\u9ed8\u8ba4\u662f rfc3164<\/p>\n<h1>max\u3001min\uff1a<\/h1>\n<p>\u8bbe\u7f6e\u6700\u5c0f\u7ea7\u522b\u7684\u65e5\u5fd7\uff0c\u6700\u5927\u7ea7\u522b\u7684\u65e5\u5fd7\u3002<\/p>\n<h1>\u4e3e\u51e0\u4e2a\u5e38\u7528\u7684\u4f8b\u5b50\u5427<\/h1>\n<pre>log 192.168.80.110 local0\r\n#\u6700\u7b80\u5355\u7684\u914d\u7f6e,\u6b64\u65f6len\u9ed8\u8ba41024,format\u9ed8\u8ba4rfc3164,\u8bb0\u5f55\u6240\u6709\u7684\u65e5\u5fd7\u7ea7\u522b\u3002\r\n\r\nlog 192.168.80.110:514 local0 warning\r\n#\u5c06\u6d88\u606f\u53d1\u9001\u7ed9514\u7aef\u53e3\uff08UDP\uff09\u3002\u8bb0\u5f55warning\u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7\r\n\r\nlog 192.168.80.110 local0 warning err\r\n#\u8bb0\u5f55warning\u5230err\u7ea7\u522b\u95f4\u7684\u65e5\u5fd7\r\n\r\nlog 192.168.80.110 local0 err err\r\n#\u53ea\u8bb0\u5f55err\u7ea7\u522b\u7684\u65e5\u5fd7\r\n\r\nlog 192.168.80.110:514 len 80 format rfc5424 local0 err err\r\n#\u622a\u53d616\u4e2a\u5b57\u7b26\u957f\u5ea6,\u4f7f\u7528rfc5424\u6d88\u606f\u89c4\u8303,\u5728\u8bbe\u5907local0\u53ea\u8bb0\u5f55err\u7ea7\u522b\u7684\u4fe1\u606f\r\n\r\nlog 192.168.80.110 local0\r\n#\u8bb0\u5f55access\u7684\u65e5\u5fd7\r\n\r\nlog 192.168.80.121 local1 emerg notice\r\n#\u8bb0\u5f55error\u7684\u65e5\u5fd7,\u5305\u62ecnotice\u548cwarning<\/pre>\n<h1>\u00a0\u548cLog\u76f8\u5173\u7684\u914d\u7f6e\uff1a<\/h1>\n<h1>log-send-hostname\u00a0\u4ec5\u652f\u6301global<\/h1>\n<p>\u8bbe\u7f6e\u65e5\u5fd7\u4e2dhost\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>log-send-hostname www.taisha.org<\/pre>\n<pre>Feb 15 09:45:57 localhost.localdomain haproxy[5062] 192.168\r\nFeb 15 09:45:57 121.110.com haproxy[5062]: 192.168.80.1:61462 [15\/Feb\/2017:09:45:57.26\r\n\r\n#\u5bf9\u6bd4#\r\n\r\nFeb 15 09:54:41 www.taisha.org haproxy[5067]: Proxy admin_stats started.\r\nFeb 15 09:54:41 www.taisha.org haproxy[5067]: Proxy webserver started.<\/pre>\n<h1>log-tag\u00a0\u652f\u6301global\u3001defaults\u3001frontend \u3001backend\u3001listen<\/h1>\n<p>\u4f8b\u5982\uff1alog-tag taisha\uff0c\u4e00\u822c\u4e0d\u7528\u8bbe\u7f6e\uff0c\u6216\u8005\u8bbe\u7f6e\u6210haproxy<\/p>\n<pre>Feb 15 09:54:41 www.taisha.org haproxy[5067]: Proxy admin_stats started.\r\nFeb 15 09:54:41 www.taisha.org haproxy[5067]: Proxy webserver started.\r\n\r\n#\u5bf9\u6bd4#\r\n\r\nFeb 15 09:54:41 www.taisha.org taisha[5067]: Proxy admin_stats started.\r\nFeb 15 09:54:41 www.taisha.org taisha[5067]: Proxy webserver started.<\/pre>\n<h1>\u00a0log global\u00a0\u652f\u6301defaults\u3001frontend\u3001backend \u3001listen<\/h1>\n<p>\u5f53\u524d\u6a21\u5757\u4f7f\u7528global\u4e2d\u8bbe\u7f6e\u7684\u65e5\u5fd7\u683c\u5f0f\u3002<\/p>\n<h1>no log\u00a0\u652f\u6301defaults\u3001frontend\u3001backend \u3001listen<\/h1>\n<p>\u7981\u6b62\u5199\u65e5\u5fd7<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5b98\u65b9\u7684\u6587\u6863\u4e2d\uff1ahttp:\/\/cbonte.github.io\/haproxy-dconv\/1.7\/configuration.html#log \u5b9a\u4e49Log\u7684\u4f7f\u7528\u683c\u5f0f\uff1a log &lt;address&gt; [len &lt;length&gt;] [format &lt;format&gt;] &lt;facility&gt; [max level [min level]] #\u652f\u6301global\u3001defaults\u3001frontend\u3001backend\u3001listen Tips 1\uff1alog \u652f\u6301\u591a\u6761\uff0c\u5728\u914d\u7f6e\u4e2d\u53ef\u4ee5\u914d\u7f6e\u591a\u6761log\uff0c\u4f8b\u5982\u914d\u7f6eaccess\uff0cerror 2\u4e2a\u65e5\u5fd7. Tips 2\uff1a\u65e5\u5fd7\u7684\u7ea7\u522b emerg\u00a0 alert\u00a0 crit\u00a0\u00a0 err\u00a0\u00a0\u00a0 warning notice info\u00a0 debug\uff0c\u51718\u4e2a \u4ece\u4f7f\u7528\u683c\u5f0f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230 &lt;address&gt; &lt;facility&gt;\u662f\u5fc5\u9009\u7684. address\uff1a \u652f\u6301IPv4\u3001IPv6\u3001socket\uff0c\u4e0d\u4e00\u5b9a\u662f\u672c\u5730\u7684IP facility\uff1a \u53c2\u8003\uff1aHaproxy\u4e2d\u7684log\u7684\u8bbe\u7f6e\u539f\u7406\u89e3\u6790 len\uff1a \u65e5\u5fd7\u7684\u6700\u5927\u957f\u5ea6\uff0c\u5982\u679c\u5b9e\u9645\u65e5\u5fd7\u6d88\u606f\u5927\u4e8e\u8fd9\u4e2a\u503c\uff0c\u5c06\u88ab\u622a\u53d6\u540e\u53d1\u9001\u3002\u9ed8\u8ba4\u662f1024\uff0c\u8be5\u503c\u7684\u533a\u522b80 \u2013 65535\uff0c\u4e0d\u5728\u8fd9\u4e2a\u533a\u95f4\u5c06\u65e0\u6cd5\u542f\u52a8\u3002 format\uff1a \u65e5\u5fd7\u683c\u5f0f\u89c4\u8303\uff0c\u53ef\u9009\u9879rfc3164\u3001rfc5424\uff0c\u9ed8\u8ba4\u662f rfc3164 max\u3001min\uff1a \u8bbe\u7f6e\u6700\u5c0f\u7ea7\u522b\u7684\u65e5\u5fd7\uff0c\u6700\u5927\u7ea7\u522b\u7684\u65e5\u5fd7\u3002 \u4e3e\u51e0\u4e2a\u5e38\u7528\u7684\u4f8b\u5b50\u5427 log 192.168.80.110 local0 #\u6700\u7b80\u5355\u7684\u914d\u7f6e,\u6b64\u65f6len\u9ed8\u8ba41024,format\u9ed8\u8ba4rfc3164,\u8bb0\u5f55\u6240\u6709\u7684\u65e5\u5fd7\u7ea7\u522b\u3002 log 192.168.80.110:514 local0 warning #\u5c06\u6d88\u606f\u53d1\u9001\u7ed9514\u7aef\u53e3\uff08UDP\uff09\u3002\u8bb0\u5f55warning\u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7 log [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18653","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18653"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18653\/revisions"}],"predecessor-version":[{"id":18654,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18653\/revisions\/18654"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}