Files
coredns/plugin/log/README.md

109 lines
2.5 KiB
Markdown
Raw Normal View History

# log
2016-03-19 11:16:08 +00:00
## Name
*log* - enables query logging to standard output.
## Description
By just using *log* you dump all queries (and parts for the reply) on standard output. Options exist
to tweak the output a little.
Note that for busy servers this will incur a performance hit.
2016-03-19 11:16:08 +00:00
## Syntax
~~~ txt
2016-03-19 11:16:08 +00:00
log
~~~
* With no arguments, a query log entry is written to *stdout* in the common log format for all requests
2016-03-19 11:16:08 +00:00
Or if you want/need slightly more control:
2016-03-19 11:16:08 +00:00
~~~ txt
log [NAME] [FORMAT]
2016-03-19 11:16:08 +00:00
~~~
* `NAME` is the name to match in order to be logged
* `FORMAT` is the log format to use (default is Common Log Format)
2016-03-19 11:16:08 +00:00
You can further specify the class of responses that get logged:
~~~ txt
log [NAME] [FORMAT] {
class [success|denial|error|all]
}
~~~
Here `success` `denial` and `error` denotes the class of responses that should be logged. The
classes have the following meaning:
* `success`: successful response
* `denial`: either NXDOMAIN or NODATA (name exists, type does not)
2016-11-09 13:02:06 +00:00
* `error`: SERVFAIL, NOTIMP, REFUSED, etc. Anything that indicates the remote server is not willing to
resolve the request.
2016-11-09 13:02:06 +00:00
* `all`: the default - nothing is specified.
2016-11-09 13:02:06 +00:00
If no class is specified, it defaults to *all*.
2016-03-19 11:16:08 +00:00
## Log Format
You can specify a custom log format with any placeholder values. Log supports both request and
response placeholders.
The following place holders are supported:
* `{type}`: qtype of the request
* `{name}`: qname of the request
* `{class}`: qclass of the request
* `{proto}`: protocol used (tcp or udp)
* `{when}`: time of the query
* `{remote}`: client's IP address
* `{size}`: request size in bytes
* `{port}`: client's port
* `{duration}`: response duration
* `{rcode}`: response RCODE
* `{rsize}`: response size
* `{>rflags}`: response flags, each set flag will be displayed, e.g. "aa, tc". This includes the qr
bit as well.
* `{>bufsize}`: the EDNS0 buffer size advertised in the query
* `{>do}`: is the EDNS0 DO (DNSSEC OK) bit set in the query
* `{>id}`: query ID
* `{>opcode}`: query OPCODE
The default Common Log Format is:
~~~ txt
`{remote} - [{when}] {>id} "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}`
~~~
2016-03-19 11:16:08 +00:00
## Examples
Log all requests to stdout
2016-03-19 11:16:08 +00:00
~~~ corefile
. {
log
whoami
}
2016-03-19 11:16:08 +00:00
~~~
Custom log format, for all zones (`.`)
2016-03-19 11:16:08 +00:00
~~~ corefile
. {
log . "{proto} Request: {name} {type} {>id}"
}
2016-03-19 11:16:08 +00:00
~~~
Only log denials for example.org (and below to a file)
~~~ corefile
. {
log example.org {
class denial
}
}
~~~