4

I'm trying to manually write an entry into journald from Python. Is there a way to do this?

Thanks for any insights.

-Paul

witch359
  • 41
  • 3
  • Duplicate of https://stackoverflow.com/questions/34588421/how-to-log-to-journald-systemd-via-python – Federico Jul 10 '19 at 16:19

1 Answers1

2

If by journald you are referring to the systemd journal, then a simple search for "journald python api" yields:

https://github.com/systemd/python-systemd

Usage

Quick example:

from systemd import journal

journal.send('Hello world')
journal.send('Hello, again, world', FIELD2='Greetings!', FIELD3='Guten tag')
journal.send('Binary message', BINARY=b'\xde\xad\xbe\xef')
mblakele
  • 7,782
  • 27
  • 45
Chen Levy
  • 15,438
  • 17
  • 74
  • 92