Logging in systemd environment

Aleksander Morgado aleksander at aleksander.es
Wed May 17 13:33:15 UTC 2017


Hey,

>
> I tried to integrate ModemManager in our environment where the
> modemmanager is started as systemd unit and logging is stored into the
> journal.
>
> I tried different settings, using the default syslog mechanism and using
> the --log-file=/dev/stderr option (and setting up the systemd unit to
> forward StandardOutput=journal) and found the log messages to contain
> too much meta information which are already provided by syslog/journal
> itself, including:
>
> - program name
> - pid
> - log level
> - timestamp
>
> This makes the log messages quite clumsy to work with.
>

Yes

> I would like to integrate some form to either send messages directly to
> syslog in _mm_log or to directly use the journald logging with functions
> like sd_journal_send. The latter could retain support for adding meta
> information on the function and the code line in the log output.
>
> I prototyped some code replacing the _mm_log and would like to know what
> is the best way to integrate such optional support into the upstream
> code base.
>
> A simple idea would be to create an additional function pointer which is
> used in _mm_log to multiplex the log output. One version could be used
> for outputting to the logfile (where currently logfd is checked),
> another version could be used for syslog and a third one for logging
> to the journal.
>
> For logging to the journal either some configure option could be added
> or a command line option similar to the logfile option.
>

Both?

> What would be your preferences?
>

I have no idea what other similar projects do w.r.t. the systemd
journal, but I wouldn't mind add support for it.

Ideally, the systemd journal support should be automatically enabled
during the build if systemd is found (e.g. as we do with
--with-suspend-resume). It should be possible to explicitly disable it
as well. This could be --with-systemd-journal=[yes|no|auto].

And then, the ModemManager program should have a specific option to
dump logs via the systemd journal, e.g. --log-journal.  Something like
that.

What do you think?

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list