[systemd-devel] Why are the priorities of stdout and stderr the same

Lennart Poettering lennart at poettering.net
Fri Aug 25 08:58:24 UTC 2023


On Do, 24.08.23 16:31, Cecil Westerhof (cldwesterhof at gmail.com) wrote:

> Normally in a script when something is send to stdout it is seen as an
> error has occurred.
> But in systemd both get a priority of 6 (info).
> Why does stderr not get a priority of 3 (err), or at least lower as
> stdout?

stderr is a bit of a misnomer, it's not just for errors, it's also for
progress output, informational output and so, basically everything
that is not considered the primary output contents that one would want
to propagate in pipelines.

We should not "assume the worst", hence given that the stderr stream
is typically used for all kinds of informational messages we should
not always assume its an error, because quite often its just
informational.

Hence, we use LOG_INFO if we have no clue simply because that's the
"best assumption".

We generally recommend apps to use syslog() or sd-journal APIs to
generate their log messages and specify the log level for each message
explicitly, to avoid any doubts. Many programming language's logging
frameworks natively have support for these.

> Now when I want the things send to stderr I also get the things send to
> stdout.

I can't parse that.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list