user137717
user137717

Reputation: 2165

Cannot write to varnishlog or syslog from varnish

I am trying to debug my .vcl files. I want to use vmod_std and std.log or std.syslog to create some output and trace the path of my requests. std.syslog is not writing to var/log/syslog. I looked at the 50-default.conf for rsyslog.d and tried restarting the service. std.log causes varnish compilation to fail with a message like

*** Killing all processes...
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/99-varnish.sh...
Message from VCC-compiler:
Expected an action, 'if', '{' or '}'
('routines.vcl' Line 84 Pos 3)
  std.log("********* FIND THIS IN THE LOG **************");
--#######--------------------------------------------------

Running VCC-compiler failed, exit 1

VCL compilation failed
*** /etc/my_init.d/99-varnish.sh failed with status 2

The subroutine containing that logging is just

sub cache_this {
  std.log("log text");
  return(lookup);
}

This is all making it extremely difficult to debug. I am using Varnish 3.0

Upvotes: 0

Views: 1107

Answers (1)

Benjamin Baumann
Benjamin Baumann

Reputation: 4065

std.log should compile. Did you import std at the beginning of your vcl file?

import std;

sub cache_this {
  std.log("log text");
  return(lookup);
}

If this compile, you should be able to see your log (among others) with varnishlog ...

Upvotes: 1

Related Questions