The thing that jumped out at me in the original code was this:
use Sys::Syslog qw(:standard :macros);
use Sys::Syslog qw(: DEFAULT setlogsock);
The space between the colon and the word DEFAULT in the last line is an error, and will stop the code from compiling. That might be a typo here. Still, I think all you need is this one line:
use Sys::Syslog qw(:standard :extended);
:extended is for the setlogsock function; everything else should be covered by :standard.
But I don't know if it's possible to log to two locations simultaneously with the module. I don't have a remote machine to test with.
There are a few other modules for logging to remote computers, such as Net::Syslog
. You could use one module for local logs, and the other to communicate with the remote system.
Another way of doing this would be to log locally in your script, and then occasionally copy your log file to a remote machine with at cron process. Here's a script
someone has provided to do that job in perl. You can examine the code here at Github
and see that he is using Sys::Syslog to do the job. Fairly short script; reading through that may show something missing from your own code.