Re: multilog prematurely rotates logs if one logdir is regular file
Erwin Hoffmann <[email protected]> Thu, 11 Aug 2022 20:45:54 +0200
| Newsgroups | gmane.comp.djb.syslog |
|---|---|
| Organization | FEHCom |
| Message-ID | <[email protected]> |
--=-lOhOH9g7jIxIFXYT9dEf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Martin, Am Donnerstag, dem 11.08.2022 um 00:46 +0200 schrieb Martin Castillo: > Hi, >=20 > for my dnscache service I wanted multilog to create a status file. > I tried this, but initially forgot the '=3D' before the last argument: >=20 > #!/bin/sh > touch /run/log/dnscache.stats; > chown log:log /run/log/dnscache.stats; > exec chpst -u log multilog t s10000000 /var/log/dnscache \ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '-*' '+*stats *' /run/lo= g/dnscache.stats >=20 > As a result, multilog immediately quit and was restarted every > second.=20 > That's okay. But what I didn't expect was to have my logs in=20 > /var/log/dnscache/ to be completely replaced by empty files! >=20 > Every time multilog was started, it rotated current (even when empty) > and deleted the oldest file. It's quite unfortunate that such a > 'typo'=20 > deletes your log files. >=20 > When I tried to reproduce this, I noticed that normally when multilog > is=20 > killed, it sets the execute bit on 'current'. But when it aborts in > the=20 > mentioned error case, it does not. When it starts, it rotates > 'current'=20 > if it's not executable by owner. >=20 > Maybe it should (1) check for an empty 'current' file and not rotate > in=20 > that case or (2) properly close (mark executable/ doing the > equivalent=20 > of c_quit()) those files in logdirs that are not related to the > error.=20 > Though these may not be the best fixes, as I'm not too familiar with > the=20 > code. that sounds unfortunate. However, I'm not the 'owner' of multilog; which is still DJB. In any case, logging is very delicate by all aspects and the best practice is, to verify the changes appplied and that logging is still happening. Logging is done using buffer on FD2. If the buffer can't be emptied, the application is stalled. Very unfortunate; but this the way it is.=20 On the server side, I can't do much. It is the user to care about logging. If you are on Linux, you may use Lennart Poettering's systemd and its logging facilicates. You also can check for Laurent Bercot's s6 utilities; but I can't tell, if they include a multilog alternative. You may also use qmail's splogger to feed the syslog facility with dnscache's output. Sorry. Regards. --eh.=20 >=20 > Martin Castillo --=20 Dr. Erwin Hoffmann | www.fehcom.de PGP key-id: 20FD6E671A94DC1E PGP key-fingerprint: 8C6B 155B 0FDA 64F1 BCCE A6B9 20FD 6E67 1A94 DC1E --=-lOhOH9g7jIxIFXYT9dEf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEjGsVWw/aZPG8zqa5IP1uZxqU3B4FAmL1TmIACgkQIP1uZxqU 3B7sIQgAsAl6cFh03OXco90kKA8gcyLhZNISbdtWUaEZf9CqtRzmnwiQpmIKjEKQ rCqEXKTcfrZ8k6h7u8HDzHWqQ67KXEjaKT64xJGB/f6DoggkRdnAOCSOQ8ca1VXD qfLEm1rXCbeJhlXY8AihK3c2QtHFIeW59fLmLTYgdsYMYU6eNQ6sZsS2y2QARZm+ 9yqdXAHrHhvrTJxb68f033pFqw3kaFJf/i/qsZhj+Dz5wfWXSCz+dhFDrTZGLN+f 37IM/DTqws4KwFkcZ8NKMnX7lE5aaVAvE/Kc8xv3ZnqCoW8pMw/yyaIPPt5pUe80 HAf2GUJzW0b5L491CP5rcR1VkQO5Sw== =NKdQ -----END PGP SIGNATURE----- --=-lOhOH9g7jIxIFXYT9dEf--