Re: ca catchall logger prefix log lines with service names?

From: Laurent Bercot <>
Date: Tue, 25 Oct 2022 16:12:43 +0000

>I am trying to figure out if I can set up svscan catchall logger in such
>a way that it prepends a service name to every log line, so that it can
>be clear where the log came from.
>I am trying to avoid s6-rc setup where I need to explicitly create a
>matching logger service.

  You are saying "I want to use s6 without adopting s6 idioms because
I'm used to the way other supervisors do things, even when they're
giant hacks." :)

  It's much easier to have one dedicated set of logs per service, and
merge them later if that's what you want, than to have one big blob of
logs and separate them later for analysis. In other words: "cat | sort"
is cheaper than a series of "grep".

  The catch-all logger is exactly what it says: a catch-all. It only
gets the logs that are not diverted; it's not supposed to get
*everything* - although it can, if that's what you want, but then as
you noticed you get everything as is: output from the services go
directly to the catch-all logger. There is no intermediary process
that can prepend your log lines with information, because the services
have their output directly plugged into the pipe to the catch-all

  The only way to modify the log lines is to insert an additional
process between your service and the catch-all logger that performs
the modification. And the simplest way to achieve that is to have
a foo/log service (or a foo-log consumer, if you're using s6-rc) for
every foo producer, that processes its stdin and writes the modified
lines to stdout, something like

   s6-format-filter "foo: %s"

  But that's still defining a consumer for your service. There is,
unfortunately, no way to do that without a consumer for every service.
And if you're going to add consumers anyway, you may as well write
dedicated loggers directly instead of line processors that send
everything back to the catch-all logger.

  Note that it's not s6 being difficult; it's s6 being out of the way
by default, by not touching your logs. If another supervisor allows
you to modify log lines by default, it means it's inserting itself
between the service and its logger, which is terribly inefficient.

>But creates a log file where all logs from all services are mixed up and
>are impossible to distinguish. There is already a strange looking thing
>prepended to every line (_at_400000006356da4b2cb3ba0a - a timestamp?)

  Yes, it's a TAI64N timestamp. Process the file through s6-tai64nlocal
to get human-readable timestamps. One of the advantages of TAI64N stamps
is that they're alphabetically sorted, so you can merge several log
files into one via "cat log1 log2 log3... | sort".

Received on Tue Oct 25 2022 - 18:12:43 CEST

This archive was generated by hypermail 2.4.0 : Tue Oct 25 2022 - 18:13:12 CEST