Conditional Logging ( using varnishncsa )
Maninder Singh
mandys at gmail.com
Thu Nov 7 06:32:14 UTC 2019
Hi,
We have logging turned on using varnishncsa.
/usr/bin/varnishncsa -a -w /var/log/varnish/varnishncsa.log -D -f
/etc/sysconfig/varnishncsa
Here is what's defined in varnishncsa
%{X-Forwarded-For}i %l %u %t %D \"%r\" %s %b \"%{Referer}i\"
\"%{User-agent}i\" \"%{Host}i\" %{Varnish:hitmiss}x
However, this would log EVERY request that goes through varnish.
We have a monitoring server that hits it aggressively ( and also static
files ).
x.x.x.x - - [07/Nov/2019:00:22:53 -0600] 2080 "GET
http://localhost/index.php HTTP/1.0" 200 8 "-" "HTTP-Monitor/1.1" "-" miss
x.x.x.x - - [07/Nov/2019:00:22:58 -0600] 2472 "GET
http://localhost/index.php HTTP/1.0" 200 8 "-" "HTTP-Monitor/1.1" "-" miss
x.x.x.x - - [07/Nov/2019:00:22:59 -0600] 1919 "GET
http://localhost/index.php HTTP/1.0" 200 8 "-" "HTTP-Monitor/1.1" "-" miss
Is there a way in which I can exclude these from varnish logs ?
In apache I would just do
SetEnvIf Request_URI
"\.(jpeg|jpg|xml|png|gif|ico|js|css|swf|woff|ttf|eot\?|js?.|css?.)$" DontLog
SetEnvIfNoCase User-Agent "(HTTP-Monitor)" DontLog
CustomLog /var/www/logs/access_80_log combined env=!DontLog
This would otherwise just keep filling up the logs.
Let me know.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20191107/89a3b8b7/attachment.html>
More information about the varnish-misc
mailing list