:: Re: [DNG] Everyone OK for using the…
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Didier Kryn
Date:  
À: dng@lists.dyne.org
Sujet: Re: [DNG] Everyone OK for using the logger program for runit logging?
Le 23/10/2018 à 18:32, Steve Litt a écrit :
> On Tue, 23 Oct 2018 11:06:52 +0200
> Didier Kryn <kryn@???> wrote:
>
>>     Logger is a way to redirect to syslog one of the output paths of
>> an application, by the mean of a pipe, or for a script to send such
>> messages. Logger reads messages and sends them by invoking the
>> syslog() function. If you force a daemon to send its messages through
>> stderr and redirect this stderr to the input of logger, you just add
>> complexity and overhead and loose flexibility; better let the daemon
>> invoke syslog() right away.
> Ahh, the preceding explains why G. Pape says runit level logs are
> required on *some* daemons, but not others. If the daemon already
> performs meaningful syslog() calls, there's no reason for further
> logging. The logger program is needed only for those daemons not
> already doing syslog() calls. The set of programs not doing syslog
> calls includes all my home-grown daemons: Being a longtime daemontools
> guy, I just write warnings and errors to stderr and know
> daemontools/runit/s6/perp will get them into the logs.
>
> So Didier: I amend my question to this: Is logger the best log
> mechanism to get stderr into the logs, for daemons not doing their own
> syslog() calls?



    I can't see how to do better than logger. The only limitation is
inherent to the very principle of redirecting stderr: the level is the
same for all messages because it is passed in the logger command line.
Instead, a daemon invoking syslog() is able to issue messages with
various levels, which makes a lot more sense.


>
> Which means on a lot of services don't get runit level logs at all.
> Which matches my Void Linux system, where 10 out of 71 daemons use a
> log. But some of those are pretty important:
>
> [root@mydesk sv]# ls -1dF */log
> docker/log/
> mysqld/log/
> ndhc/log/
> nmbd/log/
> ntpd/log/
> openntpd/log/
> postgresql/log/
> smbd/log/
> sndiod/log/
> socklog-unix/log/
> [root@mydesk sv]#
>

    Well, the default configuration of the syslog daemon (eg rsyslog)
is to not write the message level in the log file; therefore it is
impossible to see if the daemon uses syslog() or mimics the default
syslog format when writing directly to the file. But, AFAIR, you can
define in rsyslog.conf the format of the various log files, and you can
include the level. More usefully, you can dispatch messages to different
files (or output methods) depending on the level.

    I have checked for ntpd. The manual says that, by default, it
writes to the system log file. This isn't very clear. It seems to me it
uses the syslog socket because it writes to /var/log/daemon.log which
also collects the messages of several other daemons, and I think it
would cause problems if another daemon than the syslog server was
writing to this file, and also it would be fucked up by the operation of
logrotate.

    FYI, logrotate periodically renames the log files by adding them a
dot and a number, and compresses/deletes the old log files, then sends a
signal to the syslog server to tell it to re-open its output files.

    I didn't check for the others.

    Didier