Sys::Syslog
use Sys::Syslog; # Misses setlogsock.
use Sys::Syslog qw(:DEFAULT setlogsock); # Also gets setlogsock.
openlog($program, 'cons,pid', 'user');
syslog('info', 'this is another test');
syslog('mail|warning', 'this is a better test: %d', time());
closelog();
syslog('debug', 'this is the last test');
setlogsock('unix');
openlog("$program $$", 'ndelay', 'user');
syslog('info', 'problem was %m'); # %m == $! in syslogese
syslog('notice', 'fooprogram: this is really done');
setlogsock("unix"); # "inet" or "unix"
openlog("myprogname", $logopt, $facility);
syslog($priority, $format, @args);
$oldmask = setlogmask($mask_priority);
closelog();The Sys::Syslog module acts like your C
library's syslog (3) function, sending
messages to your system log daemon, syslogd
(8). It is especially useful in daemons and other programs
lacking a terminal to receive diagnostic output, or for
security-minded programs that want to produce a more lasting record of
their actions (or someone else's actions). Supported functions
are:
openlogIDENT,OPTLIST,FACILITYEstablishes a connection with your friendly syslog daemon.
IDENTis the string to log messages under (like$0, your program name).OPTLISTis a string with comma-separated options such as "cons", "pid", and "ndelay".FACILITYis something like "auth", "daemon", "kern", "lpr", "mail", "news" or "user" for system programs, and one of "local0".. "local7" for local ones. Further messages are logged using the given facility and identifying string. ...