From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21459 invoked from network); 13 Jun 2020 18:51:42 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 13 Jun 2020 18:51:42 -0000 Received: (qmail 654 invoked by uid 89); 13 Jun 2020 18:52:04 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 645 invoked from network); 13 Jun 2020 18:52:03 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; h=X-Originating-IP:Date:From:To:Subject:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; s=default; d=troubleshooters.com; b=Osqx1TPTngDGR+Wzt2JrfMtcFcr3mCNej1yAnNXJEhjwKBG/Gn10CiOfpCV8Lw+ySlCNlZB0YGeUtuzeeaJJCGc+q++MpsxNR9c2NScKX1oWOJ/YXHkdDFQPA5QNSF430zwIRyVGHnvR7WwH13i1XbptIqBStvUG6cE1HziwPWU=; DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/simple; d=troubleshooters.com; s=default; t=1592074288; bh=HsAcB2/HfNZsYt0dLan+8rBQYZU=; l=3076; h=X-Originating-IP:Date:From:To:Subject:Message-ID:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding; b=GtSQwormQ20v9TCARlKe80pr/0vFBMm1eLIyZy1ugO+7v4B6eS6yxD91zhwGEeAjb b+G27zkFNNlCCaTDVKyhuZwINwLACubEcIIrHyRI4epwfHylOXltnJnucY5T+6N5ib PHkaAq0hVPtgBWJJw8hpSnbB+SQ1Bwxb9tatTEOU= X-Originating-IP: [184.90.190.71] Date: Sat, 13 Jun 2020 14:51:27 -0400 From: Steve Litt To: supervision@list.skarnet.org Subject: Re: Logging in a web server context Message-ID: <20200613145127.632450b0@mydesk.domain.cxm> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, 13 Jun 2020 10:41:24 +0200 Carl Winb=C3=A4ck wrote: > Hi folks! >=20 > Is it possible when using s6-svscan/s6-supervise to somehow arrange so > that a daemon=E2=80=99s stdout is sent to one logdir and stderr to another > logdir? Hi Carl, Many people have given excellent answers, some of which were over my head. I personally think it's possible, with or without s6-rc, and will do my best to explain that in this email. Before I'd ever used s6 or runit, I used daemontools. With daemontools, and therefore I assume with everything, if you didn't use one of those log-handling daemons like syslog, your service directory acquired a directory called "main", and inside "main" was your log file, nicely rotated by daemontools (I assume). So like somebody said, you don't get the fan-in fan-out, you don't need to write the daemon in the message, and you don't need complex parsing to extract messages from a specific daemon. I'd imagine that's possible in all daemontools-inspired process supervisors such as s6. Nowadays I run one of those log gathering programs, at the suggestion of the experts on the Void Linux IRC channel, but maybe I'll switch back if possible. As I remember from daemontools, it captured only stdout for logging. So, if you wanted it to record both, you did a little fake to get it to=20 record both: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D exec 2>&1 exec nginx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D But the preceding is exactly what you don't want: You don't want to mix stderr and stdout. So perhaps something like the following: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D exec 2>main/stderr.log exec nginx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D I *think* the preceding would work for you, but I don't think you'd get log rotation, a timestamp and maybe some other needed stuff. So I think you could do the following: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D exec 2>stderr.intermediate | stderrhandler.sh main exec nginx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Sorry for the contrived nature of line 1 of the preceding. I'm sure there must be something more direct that doesn't require an intermediate file, but I couldn't quickly find it using either /bin/sh or execline. Anyway, perhaps stderrhandler.sh could be made to do log rotation too, as well as tacking on a timestamp. If I'm correct about this, the supervisor itself puts the stdout log in ./main/whatever.log and rotates the log. Meanwhile, stderrhandler.sh puts stderr into a different log, and perhaps stderrhandler.sh could also log rotate, although I have a feeling there would be race conditions doing so. SteveT Steve Litt=20 May 2020 featured book: Troubleshooting Techniques of the Successful Technologist http://www.troubleshooters.com/techniques