<div dir="ltr">Thank you Dridi.<div><br></div><div>This worked :-)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 7 Nov 2019 at 12:31, Dridi Boukelmoune <dridi@varni.sh> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Nov 7, 2019 at 6:34 AM Maninder Singh <<a href="mailto:mandys@gmail.com" target="_blank">mandys@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> We have logging turned on using varnishncsa.<br>
><br>
> /usr/bin/varnishncsa -a -w /var/log/varnish/varnishncsa.log -D -f /etc/sysconfig/varnishncsa<br>
><br>
> Here is what's defined in varnishncsa<br>
><br>
> %{X-Forwarded-For}i %l %u %t %D \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{Host}i\" %{Varnish:hitmiss}x<br>
><br>
> However, this would log EVERY request that goes through varnish.<br>
><br>
> We have a monitoring server that hits it aggressively ( and also static files ).<br>
><br>
> x.x.x.x - - [07/Nov/2019:00:22:53 -0600] 2080 "GET <a href="http://localhost/index.php" rel="noreferrer" target="_blank">http://localhost/index.php</a> HTTP/1.0" 200 8 "-" "HTTP-Monitor/1.1" "-" miss<br>
> x.x.x.x - - [07/Nov/2019:00:22:58 -0600] 2472 "GET <a href="http://localhost/index.php" rel="noreferrer" target="_blank">http://localhost/index.php</a> HTTP/1.0" 200 8 "-" "HTTP-Monitor/1.1" "-" miss<br>
> x.x.x.x - - [07/Nov/2019:00:22:59 -0600] 1919 "GET <a href="http://localhost/index.php" rel="noreferrer" target="_blank">http://localhost/index.php</a> HTTP/1.0" 200 8 "-" "HTTP-Monitor/1.1" "-" miss<br>
><br>
> Is there a way in which I can exclude these from varnish logs ?<br>
><br>
> In apache I would just do<br>
><br>
> SetEnvIf Request_URI "\.(jpeg|jpg|xml|png|gif|ico|js|css|swf|woff|ttf|eot\?|js?.|css?.)$" DontLog<br>
> SetEnvIfNoCase User-Agent "(HTTP-Monitor)" DontLog<br>
> CustomLog /var/www/logs/access_80_log combined env=!DontLog<br>
><br>
> This would otherwise just keep filling up the logs.<br>
<br>
Do something like this with your command line:<br>
<br>
> varnishncsa [...] -q 'not (ReqHeader:User-Agent ~ "HTTP-Monitor" or ReqURL ~ "\.(jpeg|jpg|xml|png|gif|ico|js|css|swf|woff|ttf|eot\?|js?.|css?.)$")'<br>
<br>
See man varnishncsa, man vsl and man vsl-query.<br>
<br>
Dridi<br>
</blockquote></div>