2018-01-04 12:53:07 +00:00
. \" generated with Ronn/v0.7.3
. \" http://github.com/rtomayko/ronn/tree/0.7.3
.
2019-03-30 13:56:52 +00:00
.TH "COREDNS\-LOG" "7" "March 2019" "CoreDNS" "CoreDNS plugins"
2018-01-04 12:53:07 +00:00
.
.SH "NAME"
2018-01-10 11:45:12 +00:00
\fI log\fR \- enables query logging to standard output\.
2018-01-04 12:53:07 +00:00
.
.SH "DESCRIPTION"
2018-12-11 20:46:02 +00:00
By just using \fI log\fR you dump all queries (and parts for the reply) on standard output\. Options exist to tweak the output a little\. The date/time prefix on log lines is RFC3339 formatted with milliseconds\.
2018-01-04 12:53:07 +00:00
.
.P
2018-12-11 20:46:02 +00:00
Note that for busy servers logging will incur a performance hit\.
2018-01-04 12:53:07 +00:00
.
.SH "SYNTAX"
.
.nf
log
.
.fi
.
.IP "\(bu" 4
With no arguments, a query log entry is written to \fI stdout\fR in the common log format for all requests
.
.IP "" 0
.
.P
Or if you want/need slightly more control:
.
.IP "" 4
.
.nf
2019-02-27 20:32:48 +00:00
log [NAMES\. \. \. ] [FORMAT]
2018-01-04 12:53:07 +00:00
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
2019-02-27 20:32:48 +00:00
\fB NAMES\fR is the name list to match in order to be logged
2018-01-04 12:53:07 +00:00
.
.IP "\(bu" 4
2019-01-06 09:15:34 +00:00
\fB FORMAT\fR is the log format to use (default is Common Log Format), \fB {common}\fR is used as a shortcut for the Common Log Format\. You can also use \fB {combined}\fR for a format that adds the query opcode \fB {>opcode}\fR to the Common Log Format\.
2018-01-04 12:53:07 +00:00
.
.IP "" 0
.
.P
2018-04-20 07:24:19 +01:00
You can further specify the classes of responses that get logged:
2018-01-04 12:53:07 +00:00
.
.IP "" 4
.
.nf
2019-02-27 20:32:48 +00:00
log [NAMES\. \. \. ] [FORMAT] {
2018-04-20 07:24:19 +01:00
class CLASSES\. \. \.
2018-01-04 12:53:07 +00:00
}
.
.fi
.
.IP "" 0
.
2018-04-20 07:24:19 +01:00
.IP "\(bu" 4
\fB CLASSES\fR is a space\- separated list of classes of responses that should be logged
.
.IP "" 0
.
2018-01-04 12:53:07 +00:00
.P
2018-04-20 07:24:19 +01:00
The classes of responses have the following meaning:
2018-01-04 12:53:07 +00:00
.
.IP "\(bu" 4
\fB success\fR : successful response
.
.IP "\(bu" 4
2019-01-06 09:15:34 +00:00
\fB denial\fR : either NXDOMAIN or nodata responses (Name exists, type does not)\. A nodata response sets the return code to NOERROR\.
2018-01-04 12:53:07 +00:00
.
.IP "\(bu" 4
\fB error\fR : SERVFAIL, NOTIMP, REFUSED, etc\. Anything that indicates the remote server is not willing to resolve the request\.
.
.IP "\(bu" 4
2018-04-20 07:24:19 +01:00
\fB all\fR : the default \- nothing is specified\. Using of this class means that all messages will be logged whatever we mix together with "all"\.
2018-01-04 12:53:07 +00:00
.
.IP "" 0
.
.P
If no class is specified, it defaults to \fI all\fR \.
.
.SH "LOG FORMAT"
You can specify a custom log format with any placeholder values\. Log supports both request and response placeholders\.
.
.P
The following place holders are supported:
.
.IP "\(bu" 4
\fB {type}\fR : qtype of the request
.
.IP "\(bu" 4
\fB {name}\fR : qname of the request
.
.IP "\(bu" 4
\fB {class}\fR : qclass of the request
.
.IP "\(bu" 4
\fB {proto}\fR : protocol used (tcp or udp)
.
.IP "\(bu" 4
2018-12-11 20:46:02 +00:00
\fB {remote}\fR : client\' s IP address, for IPv6 addresses these are enclosed in brackets: \fB [::1]\fR
2018-01-04 12:53:07 +00:00
.
.IP "\(bu" 4
2018-12-11 20:46:02 +00:00
\fB {local}\fR : server\' s IP address, for IPv6 addresses these are enclosed in brackets: \fB [::1]\fR
2018-01-04 12:53:07 +00:00
.
.IP "\(bu" 4
\fB {size}\fR : request size in bytes
.
.IP "\(bu" 4
\fB {port}\fR : client\' s port
.
.IP "\(bu" 4
\fB {duration}\fR : response duration
.
.IP "\(bu" 4
\fB {rcode}\fR : response RCODE
.
.IP "\(bu" 4
2018-12-11 20:46:02 +00:00
\fB {rsize}\fR : raw (uncompressed), response size (a client may receive a smaller response)
2018-01-04 12:53:07 +00:00
.
.IP "\(bu" 4
2018-12-11 20:46:02 +00:00
\fB {>rflags}\fR : response flags, each set flag will be displayed, e\. g\. "aa, tc"\. This includes the qr bit as well
2018-01-04 12:53:07 +00:00
.
.IP "\(bu" 4
\fB {>bufsize}\fR : the EDNS0 buffer size advertised in the query
.
.IP "\(bu" 4
\fB {>do}\fR : is the EDNS0 DO (DNSSEC OK) bit set in the query
.
.IP "\(bu" 4
\fB {>id}\fR : query ID
.
.IP "\(bu" 4
\fB {>opcode}\fR : query OPCODE
.
2018-12-11 20:46:02 +00:00
.IP "\(bu" 4
2019-01-06 09:15:34 +00:00
\fB {common}\fR : the default Common Log Format\.
.
.IP "\(bu" 4
\fB {combined}\fR : the Common Log Format with the query opcode\.
.
.IP "\(bu" 4
\fB {/LABEL}\fR : any metadata label is accepted as a place holder if it is enclosed between \fB {/\fR and \fB }\fR , the place holder will be replaced by the corresponding metadata value or the default value \fB \- \fR if label is not defined\. See the \fI metadata\fR plugin for more information\.
2018-12-11 20:46:02 +00:00
.
2018-01-04 12:53:07 +00:00
.IP "" 0
.
.P
The default Common Log Format is:
.
.IP "" 4
.
.nf
2018-12-11 20:46:02 +00:00
`{remote}:{port} \- {>id} "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}`
.
.fi
.
.IP "" 0
.
.P
Each of these logs will be outputted with \fB log\. Infof\fR , so a typical example looks like this:
.
.IP "" 4
.
.nf
2018\- 10\- 30T19:10:07\. 547Z [INFO] [::1]:50759 \- 29008 "A IN example\. org\. udp 41 false 4096" NOERROR qr,rd,ra,ad 68 0\. 037990251s
2018-01-04 12:53:07 +00:00
.
.fi
.
.IP "" 0
.
.SH "EXAMPLES"
Log all requests to stdout
.
.IP "" 4
.
.nf
\& \. {
log
whoami
}
.
.fi
.
.IP "" 0
.
.P
Custom log format, for all zones (\fB \. \fR )
.
.IP "" 4
.
.nf
\& \. {
log \. "{proto} Request: {name} {type} {>id}"
}
.
.fi
.
.IP "" 0
.
.P
2019-01-06 09:15:34 +00:00
Only log denials (NXDOMAIN and nodata) for example\. org (and below)
2018-01-04 12:53:07 +00:00
.
.IP "" 4
.
.nf
\& \. {
log example\. org {
class denial
}
}
.
.fi
.
.IP "" 0
2018-04-20 07:24:19 +01:00
.
.P
2019-01-06 09:15:34 +00:00
Log all queries which were not resolved successfully in the Combined Log Format\.
2018-04-20 07:24:19 +01:00
.
.IP "" 4
.
.nf
\& \. {
2019-01-06 09:15:34 +00:00
log \. {combined} {
2018-04-20 07:24:19 +01:00
class denial error
}
}
.
.fi
.
.IP "" 0
.
.P
Log all queries on which we did not get errors
.
.IP "" 4
.
.nf
\& \. {
log \. {
class denial success
}
}
.
.fi
.
.IP "" 0
.
.P
Also the multiple statements can be OR\- ed, for example, we can rewrite the above case as following:
.
.IP "" 4
.
.nf
\& \. {
log \. {
class denial
class success
}
}
.
.fi
.
.IP "" 0
2018-01-04 12:53:07 +00:00