I have a service based on parsing apache access logs, so I need to log there even when Vanish is turned on.

No I just simply tell Varnish to do not cache specific urls:

if (req.url ~ "(foo|bar)") 
   return(pass);
}

But it's heavy on resources and it should be cached. Is there any posibility to log a request on apache access log when Varnish returns a cached copy to client?

why not just use varnishes logger up front and add to the log on varnish if it was a hit or a miss

https://www.varnish-cache.org/docs/trunk/reference/varnishncsa.html

Look at the following

%{X}x
  Extended variables. Supported variables are:

  Varnish:time_firstbyte
     Time to the first byte from the backend arrived
  Varnish:hitmiss
     Whether the request was a cache hit or miss. Pipe and pass are considered misses.
  Varnish:handling
     How the request was handled, whether it was a cache hit, miss, pass, pipe or error.
  VCL_Log:key
     Output value set by std.log("key:value") in VCL.

By default it'll send everything to stdout.. but you can redirect it

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.