where can i find varnish log files? /var/log/varnish is empty
Solution 1:
by default varnish will not log anywhere.. you have to run a command to get it to show logs
You can run the command
varnishncsa
For more info on how to use that command to write to a log instead of stdout
http://www.go2linux.org/linux/2011/05/configure-varnish-logs-varnishnsca-logrotate-and-awstats-1014
Solution 2:
We could use varnishlog
too, a better remembered name compared with varnishncsa
.
We need run it with root privilege - sudo varnishlog
, otherwise somethime it will said VSM: Could not get hold of varnishd, is it running?
.
For writing log to file, we could run sudo varnishlog -w <filename>
.
-w <filename>
Redirect output to file.
The file will be overwritten unless the-a
option was specified.
If the application receives aSIGHUP
in daemon mode the file will be reopened allowing the old one to be rotated away.
The file can then be read by varnishlog and other tools with the-r
option, unless the-A
option was specified. This option is required when running in daemon mode.
For reading the log file, we could run sudo varnishlog -r <filename>
.
-r <filename>
Read log in binary file format from this file. The file can be created withvarnishlog -w filename
.