Varnish Cache Plus

JSON Logging

Varnish 6.0

Description

Both varnishlog and varnishncsa support JSON output. This is done via the line delimenated JSON format, LDJSON, which uses the newline character to seperate valid JSON objects.

varnishlog

To output LDJSON from varnishlog you add the -S argument to the varnishlog command. For example:

varnishlog -g request -S

varnishncsa

varnishncsa uses the -j argument make sure all variables are JSON safe. For proper JSON support the format string should be a valid JSON object. For example:

varnishncsa -j -F '{ "received_at": "%t", "response_bytes": %b, "request_bytes": %I, "time_taken": %D, "first_line": "%r", "status": %s }'