Vjian,
I think you're the victim of a misunderstanding. :)
> [root@xiao test]#perl mylog.pl > mylog.pl.result
The above gives me the idea that you're expecting the output of
"syslog('priority', 'message')" to be printed to standard out.
Such turns out not to be the case, though.
Sys::Syslog isn't for writing to arbitrary log files. Instead, it
provides a front-end to the syslog daemon/system, which generates
the majority of the files you'll find in '/var/log'.
Another problem is that openlog(), closelog(), and syslog() don't
return a 'true' value, as you're expecting them to. (I have no
idea why this is, though.)
Here's a stripped down version of your code that works just fine
on my FreeBSD-4.3, 5.005_03 system:
***************************************************
#!/usr/bin/perl
use Sys::Syslog;
openlog('MYPROG', 'cons,pid', 'user');
syslog('info', 'logTest');
syslog('warning', 'Something happened');
closelog();
print "ok\n"
***************************************************
Here's what I got when I ran the above:
***************************************************
Jun 4 14:49:33 morpheus MYPROG[73778]: logTest
Jun 4 14:49:33 morpheus MYPROG[73778]: Something happened
***************************************************
Again, your log entries will end up in whatever file(s)
your syslog configuration directs them to.
To make good use of syslog, you need to have a basic
understanding of facilities and priorities. You
should read the following:
syslogd(8) - Type "man 8 syslogd"
syslog.conf(5) - Type "man 5 syslog.conf"
Sys::Syslog docs - Type "perldoc Sys::Syslog"
HTH,
John
--
John Fox <[EMAIL PROTECTED]>
System Administrator, InfoStructure, Ashland OR USA
---------------------------------------------------------
"What is loved endures. And Babylon 5 ... Babylon 5 endures."
--Delenn, "Rising Stars", Babylon 5