Structured Logging Dictionary¶
This page describes the common entries of the Structured Logging component. Currently structured-logging-backend can have these values:
The
defaulttext based backend.The
systemd-journalbackend (added in version 5.2.0).The
jsonbackend (added in version 5.2.0).
The default backend¶
The default backend uses a text representation of the key-value pairs.
A line is constructed by appending all key-value pairs as key="value", separated by spaces.
The output is written by passing the resulting text line to the standard error stream and also to syslog if disable-syslog is false.
A timestamp is always prepended to the log line.
An example line looks like this:
Oct 18 08:45:21 msg="Backend does not support DNSSEC operation, not adding NSEC records" zone="example.com" level="5" prio="Notice" ts="1697611521.119"
Key names are not quoted.
Values are quoted with double quotes.
If a value contains a double quote, it is escaped with a backslash.
Backslashes in the value are escaped by prepending a backslash.
The following keys are always present:
Key |
Type |
Example |
Remarks |
|
|
|
Value is the same for all instances of
this log entry, together with
|
|
|
|
Uniquely identifies the log
entry together with the value of
|
|
|
|
The detail level of the log entry, do not confuse with loglevel. Not actively used currently. |
|
|
|
One of |
|
|
|
Number of seconds since the Unix epoch, including fractional part. |
A log entry can also have zero or more additional key-value pairs. Common keys are:
Key |
Type |
Example |
Remarks |
|
|
|
An error cause. |
|
|
|
An IP:port combination. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Text representation of DNS query type. |
|
|
|
Numeric DNS response code |
|
|
|
The name of the zone concerned. |
The systemd-journal backend¶
The systemd-journal structured logging backend uses mostly the same keys and values as the default backend, with the exceptions:
keys are capitalized as required for
systemd-journal.msgis translated toMESSAGE.priois translated toPRIORITY.tsis translated toTIMESTAMP.If the original key is in a list of keys special to
systemd-journal, it is capitalized and prepended byPDNS_. The list of special keys is: message, message_id, priority, code_file, code_line, code_func, errno, invocation_id, user_invocation_id, syslog_facility, syslog_identifier, syslog_pid, syslog_timestamp, syslog_raw, documentation, tid, unit, user_unit, object_pid.
To query the log, use a command similar to:
# journalctl -r -n 1 -o json-pretty -u pdns.service
The json backend¶
The json structured logging backend uses the same keys and values as the default backend.
An example of a log object:
{"level": "0", "msg": "Backend does not support DNSSEC operation, not adding NSEC records", "zone": "example.com", "priority": "5", "ts": "1709285994.851"}
All values are represented as strings.
The JSON log objects are written to the standard error stream, each object on its own line.