in reply to Sys::Syslog and LOG_EMERG

In short, RTFM...
From the Sys::Syslog POD

=head1 SYNOPSIS use Sys::Syslog; # all except setlogsock( +), or: use Sys::Syslog qw(:DEFAULT setlogsock); # default set, plus setl +ogsock() use Sys::Syslog qw(:standard :macros); # standard functions, pl +us macros setlogsock $sock_type; openlog $ident, $logopt, $facility; # don't forget this syslog $priority, $format, @args; $oldmask = setlogmask $mask_priority; closelog;

Note the line marked "don't forget this"

Basically, when logging to syslog you need both a priority and a facility. The command-line logger tool defaults to "user" as facility, but Sys::Syslog apparently does not, so you need the openlog call to set the facility.

Update: Actually adding openlog doesn't seem to fix it, so that wasn't much help I'm afraid.

Replies are listed 'Best First'.
Re^2: Sys::Syslog and LOG_EMERG
by pileofrogs (Priest) on Aug 11, 2006 at 23:13 UTC

    hmmm... nice guess, but it still doesn't work.

    The code:

    use Sys::Syslog qw(:standard :macros); openlog('foo', '', 'user'); syslog(LOG_EMERG,"%s","Foo");

    ...produces the same error.

      Looks like a real bug in Sys::Syslog. Below the code from Syslog.pm around line 632:

      if ($_ eq 'kern' || $num <= 0) { croak "syslog: invalid level/facility: $_" }

      Changing this to

      if ($_ eq 'kern' || $num < 0) { croak "syslog: invalid level/facility: $_" }

      makes the code work for me.

      Update:Of course that change means you won't get an error message anymore if you forget to specify a priority (e.g. syslog(LOG_USER,"test")). I'm sure someone will come up with the right solution though.