From owner-freebsd-current@FreeBSD.ORG Mon May 11 21:37:27 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0186F10656B3; Mon, 11 May 2009 21:37:27 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from asmtpout017.mac.com (asmtpout017.mac.com [17.148.16.92]) by mx1.freebsd.org (Postfix) with ESMTP id DE7638FC27; Mon, 11 May 2009 21:37:26 +0000 (UTC) (envelope-from cswiger@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from cswiger1.apple.com ([17.227.140.124]) by asmtp017.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KJI00B551EENT50@asmtp017.mac.com>; Mon, 11 May 2009 14:37:26 -0700 (PDT) Message-id: From: Chuck Swiger To: Sam Leffler In-reply-to: <4A0886F0.6030605@freebsd.org> Date: Mon, 11 May 2009 14:37:26 -0700 References: <49FE1826.4060000@FreeBSD.org> <49FE29A4.30507@root.org> <49FE5EC8.3040205@FreeBSD.org> <20090505091914.GA94521@server.vk2pj.dyndns.org> <4A00669A.10105@freebsd.org> <4A0886F0.6030605@freebsd.org> X-Mailer: Apple Mail (2.930.3) Cc: Peter Jeremy , FreeBSD-Current Subject: Re: Fighting for the power. [syslogd] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 May 2009 21:37:27 -0000 On May 11, 2009, at 1:13 PM, Sam Leffler wrote: >> You can use -l flag to syslogd to create additional logging sockets >> under your chroot'ed filesystem tree, similar to the way named & >> ntpd uses it; see syslogd_precmd() in /etc/rc.d/syslogd.... >> > > Blech, thanks. That might be a stopgap solution but it still > doesn't allow syslogd to be started earlier which is what is needed > for many/most setups. Something that's imperfect but available today is much more usable than the perfect solution tomorrow. :-) > syslogd has mountcritremote as REQUIRE to handle diskless setups but > IMO this should be (at least) configurable. But rather than argue > this nonsense I think the better solution is to do what I suggest so > syslogd can be started very early and capture everything available > (e.g. your suggestion still loses msgs logged while setting up nfs > mounts). True. I'm not sure I'd really want to set up a machine such that critical filesystems depend upon wireless networking to be up before they can be mounted, but if you've really got something which needs to run before syslogd is allowed to run, then that something needs to be able to do it's own logging. Fortunately, it's not terribly hard to write some wrappers which will log either via syslog or to a file (or both, if needed): /* initialize logging to a file, via syslog, or both... */ void init_logging() { setlogfacility(syslog_level); if (enable_syslog) logmask |= LF_SYSLOG; else logmask &= ~LF_SYSLOG; if (logfile) logmask |= LF_LOGFILE; else logmask &= ~LF_LOGFILE; if (logmask & LF_SYSLOG) { openlog("myprogram", LOG_PID|LOG_CONS, fac); } if (debug) { syslog((fac | LOG_NOTICE), "logging subsystem started..."); setlogmask(LOG_UPTO(LOG_DEBUG)); } else { if (verbose > 1) setlogmask(LOG_UPTO(LOG_DEBUG)); else setlogmask(LOG_UPTO(LOG_INFO)); } } if ((logmask & LF_LOGFILE) && logfile) { if ((ofp = fopen(logfile, "a+")) == NULL) { fprintf(stderr, "Fatal Error: unable to open and append to logfile '%s'.\n", logfile); terminate(EX_CANTCREAT); } } else if (debug) { ofp = stdout; } } /* output a message to syslog and/or the logfile/stdout */ void logdebug(char *message) { if (message == NULL) message = strerror(errno); if (logmask & LF_SYSLOG) syslog((fac | LOG_DEBUG), "%s", message); if (ofp) { fputs(message, ofp); fflush(ofp); } } [ ...repeat for loginfo(), logwarn(), etc... ] The above is triggered off of getopt() parsing flags and setting enable_syslog and/or logfile variables, but you could check whether a syslogd socket is available to scribble to or not, and decide for yourself to do your own logging to a file or not. Come to think of it, are you familiar with sending LOG_CONS to openlog()? Perhaps that would be a reasonable compromise, as you wouldn't need to move over to logging via a wrapper rather than calling syslog() directly.... Regards, -- -Chuck