{"id":990,"date":"2012-03-20T20:08:18","date_gmt":"2012-03-20T11:08:18","guid":{"rendered":"http:\/\/blog.xcir.net\/?p=990"},"modified":"2012-03-20T22:58:00","modified_gmt":"2012-03-20T13:58:00","slug":"tipsvarnishncsa-save-the-split-log-for-every-host","status":"publish","type":"post","link":"http:\/\/blog.xcir.net\/?p=990","title":{"rendered":"[tips]varnishncsa save the split log for every host"},"content":{"rendered":"<p>To save the split log for every host([hostname].access_log), Apache is easy.<br \/>\nI want the same action in varnishncsa. What should I do?<\/p>\n<p>Use the options -m [tag:regex], -w [file], -a and -D.<\/p>\n<p>-m perform a regex match to the tag&#8217;s log entry.<br \/>\n-w write log to a file.<br \/>\n-a append log. Will be overwritten if you do not specify.<br \/>\n-D Daemonize.<\/p>\n<h4>exec varnishncsa(host is a.example.net and b.example.net)<\/h4>\n<p>[code=&#8217;shell&#8217;]<br \/>\nvarnishncsa -m &#8220;RxHeader:^Host: a.example.net$&#8221; -a -w \/var\/log\/varnish\/a.example.net.access_log -D<br \/>\nvarnishncsa -m &#8220;RxHeader:^Host: b.example.net$&#8221; -a -w \/var\/log\/varnish\/b.example.net.access_log -D<br \/>\n[\/code]<\/p>\n<h4>after request<\/h4>\n<p>[code=&#8217;shell&#8217;]<br \/>\ncat a.example.net.access_log<br \/>\n192.168.1.199 &#8211; &#8211; [20\/Mar\/2012:12:51:50 +0900] &#8220;GET http:\/\/a.example.net\/a HTTP\/1.0&#8221; 200 280 &#8220;-&#8221; &#8220;Wget\/1.12 (linux-gnu)&#8221;<\/p>\n<p>cat b.example.net.access_log<br \/>\n192.168.1.199 &#8211; &#8211; [20\/Mar\/2012:12:51:59 +0900] &#8220;GET http:\/\/b.example.net\/a HTTP\/1.0&#8221; 200 280 &#8220;-&#8221; &#8220;Wget\/1.12 (linux-gnu)&#8221;<br \/>\n[\/code]<\/p>\n<p>work as expected.<\/p>\n<p>If you want to log rotate, please send the SIGHUP.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To save the split log for every host([hostname].access_log), Apache is easy. I want the same action in varnish <a href='http:\/\/blog.xcir.net\/?p=990' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,3],"tags":[5,33,38],"class_list":["post-990","post","type-post","status-publish","format-standard","hentry","category-english","category-3","tag-varnish","tag-varnish3-0-2","tag-varnishncsa","category-24-id","category-3-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"http:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=990"}],"version-history":[{"count":6,"href":"http:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/990\/revisions"}],"predecessor-version":[{"id":998,"href":"http:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/990\/revisions\/998"}],"wp:attachment":[{"href":"http:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}