supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Jan Braun <janbraun@gmx.de>
To: "Carl Winbäck" <c@tunnel53.net>
Cc: supervision@list.skarnet.org
Subject: Re: Logging in a web server context
Date: Sat, 13 Jun 2020 12:59:42 +0200	[thread overview]
Message-ID: <20200613105942.GA21613@klumpi.ignorelist.com> (raw)
In-Reply-To: <CACsCw1MhwhCcq=_VJn5N+On0=5B5oWFV6nK0FuvfUFSEKxGoJg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1832 bytes --]

Hey,

Carl Winbäck schrob:
> Is it possible when using s6-svscan/s6-supervise to somehow arrange so
> that a daemon’s stdout is sent to one logdir and stderr to another
> logdir?

I'm not completely sure about s6, but runsv (from runit) hands only the
stdout of the ./run script to the logger, and passes the stderr out of
it's own stderr. This allows you to nest two runsv instances, one for
each output channel:

$ find -type f | xargs head -n 99
==> ./inner/log/run <==
#!/bin/sh
mkdir -p stdout
svlogd -t stdout

==> ./inner/run <==
#!/bin/sh
echo stderr >&2
echo stdout
sleep 10

==> ./log/run <==
#!/bin/sh
mkdir -p stderr
svlogd -t stderr

==> ./run <==
#!/bin/sh
exec runsv inner 2>&1
$ timeout 11 runsv .
$ find -name current | xargs head
==> ./inner/log/stdout/current <==
@400000005ee4a23f2591745c stdout
@400000005ee4a24925b79614 stdout

==> ./log/stderr/current <==
@400000005ee4a23f257ae304 stderr
@400000005ee4a24925b76f04 stderr
$

Translation to s6 is left as an exercise to the reader.

> One tricky aspect of logging that is specific to web servers is that
> they emit two different categories of messages:
> 
> a) Errors and warnings
> 
> b) Info about page requests[2]

You could also run the webserver with stderr redirected to stdout, and
let s6-log/svlogd filter the messages into one of two logdirs:

$ printf 'stdout\nstderr\n' | s6-log -- '-.*err' t ./stdout f t ./stderr
$ head std*/current
==> stderr/current <==
@400000005ee4acd00efdfbe9 stderr

==> stdout/current <==
@400000005ee4acd00efd6f5e stdout

However, that's a brittle solution, because it relies on you creating
correctly-matching filter rules. Depending on the webserver's output, it
might still be feasible, but I recommend the other approach.

HTH & cheers,
    Jan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2020-06-13 10:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13  8:41 Carl Winbäck
2020-06-13 10:04 ` Casper Ti. Vector
2020-06-13 10:50   ` Carl Winbäck
2020-06-13 11:32     ` Casper Ti. Vector
2020-06-13 12:40       ` Carl Winbäck
2020-06-13 10:59 ` Jan Braun [this message]
2020-06-13 11:17   ` Carl Winbäck
2020-06-13 12:42   ` Laurent Bercot
2020-06-13 12:53     ` Laurent Bercot
2020-06-14 12:06       ` Carl Winbäck
2020-06-14 12:02     ` Carl Winbäck
     [not found] ` <20200613100522.jvixsd6fnokz3fh2@bstg>
2020-06-13 12:17   ` Carl Winbäck
2020-06-13 12:30     ` Carl Winbäck
2020-06-13 18:51 ` Steve Litt
2020-06-13 19:29   ` yianiris
2020-06-15  4:19 ` Colin Booth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200613105942.GA21613@klumpi.ignorelist.com \
    --to=janbraun@gmx.de \
    --cc=c@tunnel53.net \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).