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.