The Vespa access log format allows the logs to be processed by a number of available tools
handling JSON based (log) files.
With the ability to add custom key/value pairs to the log from any Searcher,
you can easily track the decisions done by container components for given requests.
Vespa Access Log Format
In the Vespa access log, each log event is logged as a JSON object on a single line.
The log format defines a list of fields that can be logged with every request.
In addition to these fields,
custom key/value pairs can be
logged via Searcher code. Pre-defined fields:
Name
Type
Description
Always present
ip
string
The IP address request came from
yes
time
number
UNIX timestamp with millisecond decimal precision (e.g. 1477828938.123) when request is received
yes
duration
number
The duration of the request in seconds with millisecond decimal precision (e.g. 0.123)
yes
responsesize
number
The size of the response in bytes
yes
code
number
The HTTP status code returned
yes
method
string
The HTTP method used (e.g. 'GET')
yes
uri
string
The request URI from path and beyond (e.g. '/search?query=test')
yes
version
string
The HTTP version (e.g. 'HTTP/1.1')
yes
agent
string
The user agent specified in the request
yes
host
string
The host header provided in the request
yes
scheme
string
The scheme of the request
yes
port
number
The IP port number of the interface on which the request was received
yes
remoteaddr
string
The IP address of the remote client if specified in HTTP header
no
remoteport
string
The port used from the remote client if specified in HTTP header
no
peeraddr
string
Address of immediate client making request if different from remoteaddr
no
peerport
string
Port used by immediate client making request if different from remoteport
no
user-principal
string
The name of the authenticated user (java.security.Principal.getName()) if principal is set
no
ssl-principal
string
The name of the x500 principal if client is authenticated through SSL/TLS
Note:
IP addresses can be both IPv4 addresses in standard dotted format (e.g. 127.0.0.1)
or IPv6 addresses in standard form with leading zeros omitted (e.g. 2222:1111:123:1234:0:0:0:4321).
An example log line will look like this (here, pretty-printed):
Note:
The log format is extendable by design such that the order of the fields can be changed
and new fields can be added between minor versions.
Make sure any programmatic log handling is using a proper JSON processor.
Example: Decompress, pretty-print, with human-readable timestamps:
In some cases when a request passes through an intermediate service,
this service may add HTTP headers indicating the IP address and port of the real origin client.
These values are logged as remoteaddr and remoteport respectively.
Vespa will log the contents in any of the following HTTP request headers as
remoteaddr: X-Forwarded-For, Y-RA, YahooRemoteIP or Client-IP.
If more than one of these headers are present, the precedence is in the order listed here,
i.e. X-Forwarded-For takes precedence over Y-RA.
The contents of the Y-RP HTTP request header will be logged as remoteport.
If the remote address or -port differs from those initiating the HTTP request,
the address and port for the immediate client making the request are logged as
peeraddress and peerport respectively.
Configuring Logging
Note:
The accesslog element can only be overridden on self-hosted Vespa, not on Vespa Cloud.
fileNamePattern: Pattern for log file names with time variable support
rotationInterval: Time-based rotation schedule (minutes since midnight)
rotationSize: Size-based rotation threshold in bytes (0 = disabled)
rotationScheme: Either 'sequence' or 'date'
compressionFormat: GZIP or ZSTD compression for rotated files
Logging Request Content
Vespa supports logging of request content for specific URI paths. This is useful for inspecting query content of search POST requests
or document operations of Document v1 POST/PUT requests. The request content is logged as a base64-encoded string in the JSON access log.
To configure request content logging, use the request-content element
in the accesslog configuration in services.xml.
Here is an example of how the request content appears in the JSON access log:
The file name pattern is expanded using the time when the file is created.
The following parts in the file name are expanded:
Field
Format
Meaning
Example
%Y
YYYY
Year
2003
%m
MM
Month, numeric
08
%x
MMM
Month, textual
Aug
%d
dd
Date
25
%H
HH
Hour
14
%M
mm
Minute
30
%S
ss
Seconds
35
%s
SSS
Milliseconds
123
%Z
Z
Time zone
-0400
%T
Long
System.currentTimeMillis
1349333576093
%%
%
Escape percentage
%
Log rotation
Apache httpd style log rotation can be configured by setting the rotationScheme.
There's two alternatives for the rotationScheme, sequence and date.
Rotation can be triggered by time intervals using rotationInterval and/or by file size using rotationSize.
Sequence rotation scheme
The fileNamePattern is used for the active log file name
(which in this case will often be a constant string).
At rotation, this file is given the name fileNamePattern.N where N is 1 + the largest integer found by
extracting the integers from all files ending by .<Integer> in the same directory
The fileNamePattern is used for the active log file name here too,
but the log files are not renamed at rotation.
Instead, you must specify a time-dependent fileNamePattern so that each time a new log file is created,
the name is unique.
In addition, a symlink is created pointing to the active log file.
The name of the symlink is specified using symlinkName.
The rotationInterval is a list of numbers specifying when to do rotation.
Each element represents the number of minutes since midnight.
Ending the list with '...' means continuing the
arithmetic progression
defined by the two last numbers for the rest of the day.
E.g. "0 100 240 480 ..." is expanded to "0 100 240 480 720 960 1200"
Log retention
Access logs are rotated, but not deleted by Vespa processes.
It is up to the application owner to take care of archiving of access logs.
Logging Key/Value pairs to the JSON Access Log from Searchers
To add a key/value pair to the access log from a searcher, use
query/result.getContext(true).logValue(key,value)
Such key/value pairs may be added from any thread participating in handling the
query without incurring synchronization overhead.
If the same key is logged multiple times, the values written will
be included in the log as an array of strings rather than a single string value.
The key/value pairs are added to the attributes object in the log.
An example log line will then look something like this: