{"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":"https:\/\/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<pre class=\"brush: shell; \">\n\r\nvarnishncsa -m &quot;RxHeader:^Host: a.example.net$&quot; -a -w \/var\/log\/varnish\/a.example.net.access_log -D\r\nvarnishncsa -m &quot;RxHeader:^Host: b.example.net$&quot; -a -w \/var\/log\/varnish\/b.example.net.access_log -D\r\n\n<\/pre>\n<h4>after request<\/h4>\n<pre class=\"brush: shell; \">\n\r\ncat a.example.net.access_log\r\n192.168.1.199 - - [20\/Mar\/2012:12:51:50 +0900] &quot;GET http:\/\/a.example.net\/a HTTP\/1.0&quot; 200 280 &quot;-&quot; &quot;Wget\/1.12 (linux-gnu)&quot;\r\n\r\ncat b.example.net.access_log\r\n192.168.1.199 - - [20\/Mar\/2012:12:51:59 +0900] &quot;GET http:\/\/b.example.net\/a HTTP\/1.0&quot; 200 280 &quot;-&quot; &quot;Wget\/1.12 (linux-gnu)&quot;\r\n\n<\/pre>\n<p>work as expected.<\/p>\n<p>If you want to log rotate, please send the SIGHUP.<\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D990&title=%5Btips%5Dvarnishncsa%20save%20the%20split%20log%20for%20every%20host' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_hatena_users\"><a href='\/\/b.hatena.ne.jp\/entry\/https:\/\/blog.xcir.net\/?p=990' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - [tips]varnishncsa save the split log for every host' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='\/\/b.hatena.ne.jp\/entry\/image\/https:\/\/blog.xcir.net\/?p=990' alt='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - [tips]varnishncsa save the split log for every host' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - [tips]varnishncsa save the split log for every host'   class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D990&t=%5Btips%5Dvarnishncsa%20save%20the%20split%20log%20for%20every%20host' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_linkedin\"><a href='\/\/www.linkedin.com\/shareArticle?mini=true&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D990&title=%5Btips%5Dvarnishncsa%20save%20the%20split%20log%20for%20every%20host' title='LinkedIn \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/linkedin.png' alt='LinkedIn \u306b\u30b7\u30a7\u30a2' title='LinkedIn \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/blog.xcir.net\/?p=990\" data-text=\"[tips]varnishncsa save the split log for every host\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\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='https:\/\/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":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=990"}],"version-history":[{"count":6,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/990\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/990\/revisions\/998"}],"wp:attachment":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}