Home:ALL Converter>journald *reading* API?

journald *reading* API?

Ask Time:2022-05-26T01:11:54         Author:foo

Json Formatter

journald writes binary log files; and their format is explicitly subject to change.

The Journald Reference Guide tells us, quote:

While it can be useful to get used to journalctl to read logs, it’s by no means mandatory.

So, how can we read these files? Is there a journald reading API I missed? I couldn't find any yet.

Author:foo,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72381783/journald-reading-api
KamilCuk :

Systemd (and journald) are written in C. They come with sd-journal.h header file and with C-API https://www.freedesktop.org/software/systemd/man/sd_journal_next.html# - sd_journal_open allows you to open logs and then read from them.\nOther languages - https://www.freedesktop.org/software/systemd/python-systemd/journal.html#example-polling-for-journal-events https://github.com/nyantec/rust-journald - most probably build on top of the C api.\nMoreover, journald is open source - https://github.com/systemd/systemd/blob/968680b23d1629d33deeea98b4f2b5fd106075b5/src/libsystemd/sd-journal/sd-journal.c#L1916 - and the file format is documented - https://www.freedesktop.org/wiki/Software/systemd/journal-files/ . You can re-implement your own API on top of system-specific I/O operations to read journal files.",
2022-05-25T17:54:25
yy