We are sending a lot of syslog messages from our perls script using the facility code of local2. This works really well on Red Hat but on SunOS the messages don't appear to go to local2. For example, here is a minimal script
#!/usr/bin/perl
use strict;
use warnings;
use Sys::Syslog qw(:DEFAULT :standard :macros);
openlog("", 'ndelay', 'local2');
syslog('info', "ItWorks");
`logger -p local2.info "ItWorks"`;
In this script I am sending a log via the Syslog perl module and also via the logger command. Only the second message appears to go to local2. The reason I believe it is not going to local2 is that we have a rule setup in syslog.conf file to forward local2 and only the second message gets forwarded. When I look at the 2 messages in the log file they look slightly different, I'm not sure if that is important
Sep 2 11:41:22 ssapp7001v <150>Sep 2 11:41:22 d336599: ItWorks
Sep 2 11:41:22 ssapp7001v d336599: [ID 702911 local2.info] ItWorks
I should also add that I have tried various combinations in the perl code of using local2 as a string, as a constant, specifying it in the openlog call and/or in the syslog call. None of that appears to make any difference. I could just use backticks and call logger but that is my last resort because I then have to deal with characters that might not be command line friendly plus also the performance hit of opening a new process for every log message. Unfortunately making any config changes on this server is out of the question.