[systemd-devel] util-linux logger vs systemd-cat

Lennart Poettering lennart at poettering.net
Mon May 6 14:08:35 PDT 2013


On Tue, 23.04.13 10:35, Colin Walters (walters at verbum.org) wrote:

> I found myself in a situation recently where I wanted to log
> a message from a shell script that included MESSAGE_ID.  As
> far as I can tell there's no utility binary for this.

True.

> systemd ships systemd-cat which connects to the journal, but
> it doesn't have support for structured logging; it's just a
> way to conveniently stream textual output to the journal.  But that's
> not useful to me in this context because in current GNOME-OSTree we
> already have gdm set up to log the session to the journal; what I want
> is the ability to output structured messages.
> 
> util-linux has included a tool "logger" for a log time; it wraps syslog;
> better, it's more oriented for logging a single message, which is
> convenient for shell script as in this case.
> 
> It certainly seems like it could make sense to add a command line
> switch like --struct=MESSAGE_ID=0ce153587afa4095832d233c17a88001 to
> logger.

The transport used by systemd-cat doesn't really support structured
messages. It opens a stream socket to journald, and actually passes the
resulting fd as STDIN/STDOUT to the executed program, without staying
around itself. "systemd-cat foobar" is hence much more efficient than
"foobar | logger"... journald then takes the output it gets from there
and simply splits it up on line-breaks and adds hostname/timestamp/yadda
yadda to it...

> Or is there an existing tool for this I'm missing?  Should systemd-cat
> support structured logging?

I guess the fact that systemd-cat currently doesn't use the structured
logging protocol is an implementation detail. And yeah, i guess it would
make a ton of sense to extend it to send full structured messages.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list