One aspect of Varnish that customers and enthusiasts most often ask questions about is how to make more effective use of Varnish’s powerful logging features. Logging and log management is important because your logs can be a real-time account of what is happening behind the scenes with your web traffic and transactions, resource performance, and much more. The detailed nature of logs lets you identify specific issues, anomalies or patterns and troubleshoot, sometimes getting to root causes of problems or seeing and stopping threats emerge before they can do any damage.
The Varnish distribution comes with several utility programs. The main one is the Varnish daemon varnishd. It accepts and handles HTTP requests from clients and it’s responsible for the cache itself. Among the binaries you get from your Varnish installation, there are five programs that read the Varnish Shared Memory Log (VSL), parse it or extract data from it and present it to you: varnishlog, varnishstat, varnishncsa, varnishtop and varnishhist.
In this blog post I’ll throw the possible errors you can encounter when launching one of the above mentioned programs. You might ask… why? A few weeks back I spent a lot of time trying to fix my Varnish installation, and I fell into the install-remove varnish loop in an attempt to fix it. When I realized a magic fix was never going to happen, I went through the source code and eventually fixed my Varnish.
(I could have simply destroyed my virtual machine, but I really wanted to figure out why my Varnish wasn’t happy.)