The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Mojo::Log::Syslog - syslog for Mojo projects


    use Mojo::Log::Syslog;

    $logger = new Mojo::Log::Syslog(facility => 'user',
                                    ident => 'myapp',
                                    level => 'warn');



Syslog-based logger for Mojo applications.


The Mojo::Log::Syslog constructor takes the following keyword arguments, all of which are optional:

facility => FACILITY

Sets the syslog facility to use. Valid facility names are: auth, authpriv, cron, daemon, ftp, kern, local0 through local7, lpr, mail, news, user, and uucp. See also Sys::Syslog(3), section Facilities.

The default is user.

ident => STRING

Syslog message identifier. Defaults to the base name from $0.

logopt => OPTLIST

Defines the list of options for openlog. OPTLIST is either a string with comma-separated option names or a list reference containing option names. The following two options are equivalent:

    logopt => "ndelay,pid,nowait"

    logopt => [qw(ndeay pid nowait)]

See Sys::Syslog(3) for a list of available option names.

Defaults to ndelay,pid.

level > NAME

Sets minimum logging level. See Mojo::Log, for a list of levels.


All methods are inherited from Mojo::Log. The methods debug, warn, info, and error log their messages using the corresponding syslog priorities. The method fatal uses the crit (LOG_CRIT) priority.


Using with Mojolicious::Lite

    use Mojolicious::Lite;
    use Mojo::Log::Syslog;

    my $logger = new Mojo::Log::Syslog(facility => 'local0',
                                       level => 'warn');

Using with Mojolicious

    package MyApp;
    use Mojo::Base 'Mojolicious';

    sub startup {
        my $self = shift;
        my $logger = new Mojo::Log::Syslog(facility => 'local0',
                                           level => 'warn');


Mojo::Log(3), Mojolicious(3), Mojolicious::Guides(1),