* Re: isc dhcpd won't log to stdout/stderr
2005-12-08 6:52 isc dhcpd won't log to stdout/stderr Dean Hall
@ 2005-12-08 19:04 ` Charlie Brady
0 siblings, 0 replies; 2+ messages in thread
From: Charlie Brady @ 2005-12-08 19:04 UTC (permalink / raw)
Cc: supervision
On Thu, 8 Dec 2005, Dean Hall wrote:
> I'm trying to get dhcpd (3.0.1) supervised by runsv on Gentoo Linux, and
> though dhcpd's man page says that it will log to STDERR with the "-d" flag,
> and though I'm using that flag when I run it, all logs still go straight to
> syslog. I even commented the "log-facility" directive in dhcpd.conf just in
> case. Has anyone got this version to log to STDERR successfully?
I see the same as you. Looks like a bug in dhcpd to me.
<checks>
OK, here's the story.
Don't use "-d -q", just use "-d". That'll get you stderr logging, but as
well as syslog, not instead of.
If you don't want syslog, compile with -DDEBUG (although that might make
other changes you don't want - I haven't checked what else it does).
Here's log_info(). As you can see, it logs to syslog and then to stderr
iff log_perror is non-zero:
omapip/errwarn.c
int log_info (const char *fmt, ...)
{
va_list list;
do_percentm (fbuf, fmt);
/* %Audit% This is log output. %2004.06.17,Safe%
* If we truncate we hope the user can get a hint from the log.
*/
va_start (list, fmt);
vsnprintf (mbuf, sizeof mbuf, fbuf, list);
va_end (list);
#ifndef DEBUG
syslog (log_priority | LOG_INFO, "%s", mbuf);
#endif
if (log_perror) {
write (2, mbuf, strlen (mbuf));
write (2, "\n", 1);
}
return 0;
}
server/dhcpd.c:
...
} else if (!strcmp (argv [i], "-f")) {
#ifndef DEBUG
daemon = 0;
#endif
} else if (!strcmp (argv [i], "-d")) {
#ifndef DEBUG
daemon = 0;
#endif
log_perror = -1;
} else if (!strcmp (argv [i], "-s")) {
...
} else if (!strcmp (argv [i], "-q")) {
quiet = 1;
quiet_interface_discovery = 1;
} else if (!strcmp (argv [i], "--version")) {
...
if (!quiet) {
log_info ("%s %s", message, DHCP_VERSION);
log_info (copyright);
log_info (arr);
log_info (url);
} else {
quiet = 0;
log_perror = 0;
}
...
/* If we were requested to log to stdout on the command line,
keep doing so; otherwise, stop. */
if (log_perror == -1)
log_perror = 1;
else
log_perror = 0;
...
So, -q clobbers the effect of -d on logging. And -f isn't needed if you
use -d. So just use -d, and put up with logging to syslog, or compile with
-DDEBUG, or patch the code.
^ permalink raw reply [flat|nested] 2+ messages in thread