++ed by:
1 non-PAUSE user
Author image Lubomir Rintel
and 1 contributors


Log::Journald - Send messages to a systemd journal


  use Log::Journald;
  use Sys::Syslog qw/:macros/;

  # Easy.
  journal_log(LOG_INFO, "Hello (1) from PID $$!");

  # Send arbitrary fields, even binary data
  Log::Journald::send(PRIORITY => LOG_INFO,
       MESSAGE => "Hello (2) from PID $$!",
       _YOLO => "SW\x00AG")
       or warn "Could not send log: $!";

  # Raw
       "MESSAGE=Hello (3) from PID $$!");

Please consider this an alpha quality code, whose API can change at any time, until we reach version 1.00.


This module wraps sd-journal(3) APIs for easy use in Perl. It makes it possible to easily use systemd-journald.service(8)'s structured logging capabilities and includes location of the logging point in the source code in the messages.

Backends for Log::Dispatch and Log::Log4perl exist: Use Log::Dispatch::Journald and Log::Log4perl::Appender::Journald respectively.



Log a message at given priority. Exported by default.

Returns true upon success, false while setting $! on failure.

send KEY VALUE ...

Log a message with given key-value pairs. MESSAGE and PRIORITY keys are mandatory. See systemd.journal-fields(7) for list and description of known fields.

Returns true upon success, false while setting $! on failure.

sendv STRING ...

Same as above, apart from that instead of key and value pair, strings that contain key and value concatenated with "=" are expected. This avoids an extra copy and might me slightly more efficient.

Returns true upon success, false while setting $! on failure.



journal_log() terminates the message at a NUL byte. You need to use another interface to log binary data.

To get priority constants, you still need to include Sys::Syslog.

There's no way to override caller depth. Therefore if you add a wrapper for any of this module's interfaces, you'll get the location of the wrapper in the messages.

A way to disable or override inclusion of code location would be nice.


Copyright 2014 Lubomir Rintel

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Lubomir Rintel, <lkundrak@v3.sk>

The code is hosted on GitHub http://github.com/lkundrak/perl-Log-Journald. Bug fixes and feature enhancements are always welcome.