3月 202012
To save the split log for every host([hostname].access_log), Apache is easy.
I want the same action in varnishncsa. What should I do?
Use the options -m [tag:regex], -w [file], -a and -D.
-m perform a regex match to the tag’s log entry.
-w write log to a file.
-a append log. Will be overwritten if you do not specify.
-D Daemonize.
exec varnishncsa(host is a.example.net and b.example.net)
varnishncsa -m "RxHeader:^Host: a.example.net$" -a -w /var/log/varnish/a.example.net.access_log -D varnishncsa -m "RxHeader:^Host: b.example.net$" -a -w /var/log/varnish/b.example.net.access_log -D
after request
cat a.example.net.access_log 192.168.1.199 - - [20/Mar/2012:12:51:50 +0900] "GET http://a.example.net/a HTTP/1.0" 200 280 "-" "Wget/1.12 (linux-gnu)" cat b.example.net.access_log 192.168.1.199 - - [20/Mar/2012:12:51:59 +0900] "GET http://b.example.net/a HTTP/1.0" 200 280 "-" "Wget/1.12 (linux-gnu)"
work as expected.
If you want to log rotate, please send the SIGHUP.
[…] A good solution that I’ve found in the blog blox.xcir.net is to have 1 dedicated daemon for every virtual host and use the flag -m that is used to perform a regex match to the tag’s log entry so if we have 2 virtual host: linuxaria.com and l […]