Logging variable in request
I’m currently using vcl_log
to log values from vcl_recv
. I basically create an HTTP header (e.g. set req.http.X-Foo-Bar = value;
) in vcl_recv
and then read it in vcl_log
while generating the log message. The problem with this approach is that you can bloat the request sent to the origin since now those headers are included in the request.
Is there a way better way to log stuff from vcl_recv
without the need to create a useless HTTP header?
-
Hi @alex,
Two ways you can do this:
- Set
req.http.SOMETHING
in recv, unset the header in miss and pass, once it has been transferred ontobereq
, ie.unset bereq.http.SOMETHING
, which will preserve thereq.http
version for later inspection in vcl_log. - Emit your log event directly from recv, using an explicit
log
statement. You can emit log data from any VCL function, not just vcl_log.
- Set
Please sign in to leave a comment.
Comments
2 comments