Help language development. Donate to The Perl Foundation

Lumberjack::Dispatcher::Syslog cpan:JSTOWE last updated on 2021-02-05

Lumberjack::Dispatcher::Syslog - syslog dispatcher for the the Lumberjack logger


    use Lumberjack;
    use Lumberjack::Dispatcher::Syslog;

    # Add the syslog dispatcher

    class MyClass does Lumberjack::Logger {
       method start() {
           self.log-info("Starting ...");

       method do-stuff() {
          self.log-debug("Doing stuff ...");
          if $something-went-wrong {
             self.log-error("Something went wrong");
       method stop() {

    MyClass.log-level = Lumberjack::Debug;


This provides a dispatcher for [Lumberjack]( which allows you to log to your system's `syslog` facility, this may log to various log files in, for instance, `/var/log` depending on the configuration of the syslog daemon. Because the actual logging daemon being used may differ from system to system (there is syslog-ng, rsyslog, syslog "classic" etc,) you will need to refer to the local documentation or a system administrator to determine the actual logging behaviour. Some systems may for instance just drop "debug" or "trace" messages in the default configuration (or put them in separate files.)

As a "plugin" to `Lumberjack` this has no methods of its own. All of the following configuration can be passed to the constructor prior to adding it to the "dispatchers" list of `Lumberjack`.


This is the string 'ident' of the logger, it defaults to the program name.


This is the syslog facility which the logger will be opened for. It should be a value of the enumeration `Log::Syslog::Native::LogFacility`, it defaults to `Local0`. The "facility" is commonly used to determine which file the logger will place the messages, you will need to check the local configuration to determine the exact behaviour regarding the different facilities.


This is the format that is used to format the message before sending to the logger, this is described in the [Lumberjack]( documentation.

The default is "[%C - %S] : %M" which will emit "[<class> <method>] : <message>".


This is the integer callframe depth at which the formatter will try to find the details of the execution frame of the log message. The default "4" should work in most cases but you may need to adjust it if you are doing something more complicated and the subroutine name or filename are wrong.


This is a Hash mapping the `Lumberjack::Level` levels of the incoming messages to the `Log::Syslog::Native::LogLevel` "priority" of the syslog. The default should be sufficient for most uses but you can supply your own to work around a fixed configuration on your system. The "priority" may influence where and indeed, if, a message will get logged. The default mapping attempts to avoid using any priority that typically gets sent to a console rather than files.


This is a matcher for the levels that this dispatcher wishes to handle, as described in the `Lumberjack` documentation.


This is a matcher for the classes that this dispatcher wishes to handle, as described in the `Lumberjack` documentaion. This and `levels` may be particularly useful in the syslog scenaria as it enables a mapping of syslog "facilities" to different parts of an application.