[nsd-users] Log file rotation
Shane Kerr
shane at ca.afilias.info
Tue Nov 4 15:25:48 UTC 2008
Hello,
As far as I can tell, if you specify a log file for NSD it is never
rotated.
We could use syslog to give us this functionality, but we run a number
of different versions of NSD, and prefer to use the log file than
syslog.
I think a small change would be to have the server re-open the log file
when the server is reloaded would work for us. These two patches should
make that happen:
--- nsd.c Thu Sep 25 14:01:41 2008
+++ nsd.c.new Tue Nov 4 15:19:26 2008
@@ -588,8 +588,8 @@
{
if(nsd.options->identity) nsd.identity = nsd.options->identity;
}
- if (nsd.options->logfile && !log_filename) {
- log_filename = nsd.options->logfile;
+ if (log_filename) {
+ nsd.options->logfile = log_filename;
}
if(nsd.child_count == 0) {
nsd.child_count = nsd.options->server_count;
@@ -759,8 +759,8 @@
#endif /* TSIG */
/* Set up the logging... */
- log_open(LOG_PID, FACILITY, log_filename);
- if (!log_filename) {
+ log_open(LOG_PID, FACILITY, nsd.options->logfile);
+ if (!nsd.options->logfile) {
log_set_log_function(log_syslog);
}
--- server.c Thu Oct 16 14:21:28 2008
+++ server.c.new Tue Nov 4 15:16:32 2008
@@ -1034,6 +1034,8 @@
}
log_msg(LOG_WARNING, "signal received, reloading...");
+ log_finalize();
+ log_open(LOG_PID, FACILITY, nsd->options->logfile);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, reload_sockets) == -1) {
log_msg(LOG_ERR, "reload failed on socketpair: %s", strerror(errno));
--
Shane
More information about the nsd-users
mailing list