Logging to email in varnish from default.vcl file

Viewed 29
 varnish:
  image: varnish:6.0
  restart: always
  depends_on:
   - apache
  networks:
   - frontend
   - backend
   - traefik
  volumes:
   - ./docker/varnish:/etc/varnish
  ports:
   - 6081:6081

I have the following varnish config in docker.

I have the following default.vcl config:

vcl 4.0;
sub vcl_recv {
        set req.grace = 2m;

        if (req.http.Cookie !~ "(^|;\s*)(city=(.*?))(;|$)") {
           return (pass);
        }   
        # Try a cache-lookup
        return (hash);
}

How do I log to a text file when the function returns pass or returns a hash?

I tried the following, but I can't find the log.

# To 'varnishlog'
std.log("varnish log info:" + req.host);

# To syslog
std.syslog( LOG_USER|LOG_ALERT, "There is serious trouble");
0 Answers
Related