[systemd-devel] @cee {<jsondict|} spec? Was: Systemd service and structured logging

Thomas Güttler guettliml at thomas-guettler.de
Tue May 7 07:43:27 UTC 2019


Hi Mantas Mikulėnas and other members,

This looks nice:

   @cee: {<jsondict>}

For me this is new. I could find some scattered information about this.

Is there an official spec for this logging syntax?

I think it would be nice if a systemd service could log structured logs like
this via stdout.

Regards,
   Thomas Güttler


Am 06.05.19 um 11:09 schrieb Mantas Mikulėnas:
> On Mon, May 6, 2019 at 10:09 AM Thomas Güttler <guettliml at thomas-guettler.de <mailto:guettliml at thomas-guettler.de>> wrote:
> 
>     Am 03.05.19 um 13:29 schrieb Jérémy ROSEN:
>      > if you want the whole power of structured logs, you need to use the journald API
> 
> 
> On the other hand, JSON parsing might be a useful addition to journald, as apparently "@cee: {<jsondict>}" is a quite 
> common syslog format.
> 
>      > I am not sure in what language your program is written, but if you are using C, it's pretty trivial to do
>      > (and i'm pretty sure most bindings are trivial to use too)
> 
> 
>     Yes, this would work.
> 
> 
>     Solution 1:
>        My service (written Python) uses the journald API.
>        Disadvantage: My script can't be run under a different environment (without journald)
> 
> 
> I would suggest implementing support for multiple logging backends – don't call journald APIs directly and don't print 
> out JSON directly, but have abstract functions such as log_info(text, **kvpairs) or something such. That's what many 
> programs already do for file/syslog/journal backends. (Possibly just use the `logging` module in python?)
> 
> -- 
> Mantas Mikulėnas

-- 
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines


More information about the systemd-devel mailing list