10.9 Rotating Log Files
10.9.1 Problem
You want to
rotate a name server's log files.
10.9.2 Solution
BIND name servers support a limited
form of log file rotation. When you define a file channel, you can
specify that the name server keep some number of versions of the file
with the versions argument to the file
substatement. For example, this channel definition tells
the name server to save seven versions of the
named.log file:
logging {
channel "named_log" {
file "named.log" versions 7;
print-time yes;
};
};
The name server will only rotate the files when it's
restarted or reloaded, so after seven restarts or reloads,
you'll have a named.log,
named.log.1, and so on.
You can combine the
versions argument with the
size argument to tell the name server to rotate
the log file once it reaches a certain size. For example, to rotate
the log file once it reaches a megabyte in size, you could use this
channel substatement:
logging {
channel "named_log" {
file "named.log" versions 7 size 1m;
print-time yes;
};
};
10.9.3 Discussion
With a size specified, log files are only renamed when the current
log file exceeds the size limit, not on restart or reload.
Use the
keyword unlimited to keep an unlimited number of
old versions of a log file:
logging {
channel "named_log" {
file "named.log" versions unlimited size 1m;
print-time yes;
};
};
On BIND 8, unlimited is actually synonymous with
"99" for purposes of log file
rotation.
10.9.4 See Also
"The Logging Statement" in Chapter
7 of DNS and BIND.
|