Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jul 2017 01:31:26 +0700
From:      Eugene Grosbein <eugen@grosbein.net>
To:        Matthias Fechner <idefix@fechner.net>, freebsd-ports@freebsd.org
Subject:   Re: Best practice to tail a log and start it as service using rc.d scripts
Message-ID:  <595BDEFE.9020200@grosbein.net>
In-Reply-To: <34946b34-5e91-031f-b1dc-146c3ded4803@fechner.net>
References:  <62c231e8-74b0-8515-eb22-4e4edf6ff5e2@fechner.net> <595A8B47.2060705@grosbein.net> <34946b34-5e91-031f-b1dc-146c3ded4803@fechner.net>

next in thread | previous in thread | raw e-mail | index | archive | help
05.07.2017 1:02, Matthias Fechner wrote:

> Am 03.07.2017 um 20:21 schrieb Eugene Grosbein:
>> For logs written using standard syslog service, there is much
>> effective way.
>> 1. The syslogd daemon can run a subprocess and duplicate log stream to its
>> standard input. For example, write to its config:
>>
>> mail.*	"|exec nc localhost 5699 -"
>>
>> See man syslog.conf for details. You can even pipe not full log
>> but some part of it, f.e. `mail.notice' instead of `mail.*'
>> for important event only (no debug lines, no informational mesages).
> thanks for this, I will test that more in detail.
> I correctly have the problem if the mailtrain app is stopped, it closes
> the network socket which causes nc to terminate.
> This is not what I would like to have, but maybe syslog is restarting nc
> in this case?

This is documented in the syslog.conf(5) manual page I mentioned previously:

         The command will only be started once data arrives that should be
         piped to it.  If it exited later, it will be restarted as necessary.

> If not syslog is maybe not the right solution, but I will test this first.
> 
>> 2. And you need not modify system /etc/syslog.conf but create file
>> named like /usr/local/etc/syslog.d/mailtrain.conf with that single line.
>> Then use `service syslogd reload' to apply additional configuration
>> and syslogd will run your "addon" when corresponding logs is updated.
> 
> are you sure about this?
> I cannot find that described in any man page, /etc/defaults/rc.conf neither.
> I tested it but it is not working.
> Just added a file: /usr/local/etc/syslog.d/mailtrain.conf with content:
> mail.*  /var/log/maillog.err
> 
> I touched the /var/log/maillog.err and reloaded syslogd.
> But nothing appears in that file.

I should have mentioned before that this depends on FreeBSD version.
This feature presents in FreeBSD 11 and newer and was merged to 10-STABLE
but for some reason was removed from 10-STABLE several days ago
by request of jhb@.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?595BDEFE.9020200>