intelmq
intelmq copied to clipboard
[1] Systemd logging
python3-systemd allows simple logging to systemd:
>>> from systemd import journal
>>> log = logging.getLogger('custom_logger_name')
>>> log.propagate = False
>>> log.addHandler(journal.JournalHandler())
>>> log.error("Some message: %s", detail)
And in the journal (in red):
Sep 15 21:57:33 linux-5emk [23838]: Some message: adsa
So in the end we have something like this in the logs:
Sep 15 21:55:19 linux-5emk intelmq[23838]: file-output: INFO: Bot is starting.
See also python-systemd
What's the benefit over using the regular syslog?
https://github.com/mosquito/cysystemd https://github.com/systemd/python-systemd/issues/68#issuecomment-487026259