blob: 9e6576f049463dd2ab361f525392f3e87c254514 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# Log
log enables request logging. The request log is also known from some vernaculars as an access log.
## Syntax
~~~
log
~~~
* With no arguments, an query log is written to query.log in the common log format for all requests
(base name = .).
~~~
log file
~~~
* file is the log file to create (or append to). The base path is assumed to be . .
~~~
log name file [format]
~~~
* `name` is the base name to match in order to be logged
* `file` is the log file to create (or append to)
* `format` is the log format to use (default is Common Log Format)
## Log File
The log file can be any filename. It could also be stdout or stderr to write the log to the console,
or syslog to write to the system log (except on Windows). If the log file does not exist beforehand,
CoreDNS will create it before appending to it.
## Log Format
You can specify a custom log format with any placeholder values. Log supports both request and response placeholders.
## Log Rotation
If you enable log rotation, log files will be automatically maintained when they get large or old.
You can use rotation by opening a block on your first line, which can be any of the variations
described above:
~~~
log ... {
rotate {
size maxsize
age maxage
keep maxkeep
}
}
~~~
* `maxsize` is the maximum size of a log file in megabytes (MB) before it gets rotated. Default is 100 MB.
* `maxage` is the maximum age of a rotated log file in days, after which it will be deleted. Default is to never delete old files because of age.
* `maxkeep` is the maximum number of rotated log files to keep. Default is to retain all old log files.
## Examples
Log all requests to a file:
~~~
log /var/log/query.log
~~~
Custom log format:
~~~
log . ../query.log "{proto} Request: {name} {type} {>id}"
~~~
With rotation:
~~~
log query.log {
rotate {
100 # Rotate after 100 MB
age 14 # Keep log files for 14 days
keep 10 # Keep at most 10 log files
}
}
|