Sys::Syslog under Solaris

L

Loic Minier

Hi,

I have trouble using the Sys::Syslog package under Solaris. If I use
'stream', I don't get anything logged, and if I log via udp instead,
all my logs are prefixed with the program name ($ident). This doesn't
happen with other programs running on the same host.

Here's the relevant Perl :
use Sys::Syslog qw:)DEFAULT setlogsock);
#setlogsock('stream'); # doesn't work
setlogsock('inet'); # or udp
syslog('info', "test\n");

Any idea on how to get stream at work? Or to get rid of the prefix?

Thanks,
 
D

David Efflandt

Hi,

I have trouble using the Sys::Syslog package under Solaris. If I use
'stream', I don't get anything logged, and if I log via udp instead,
all my logs are prefixed with the program name ($ident). This doesn't
happen with other programs running on the same host.

Here's the relevant Perl :
use Sys::Syslog qw:)DEFAULT setlogsock);
#setlogsock('stream'); # doesn't work
setlogsock('inet'); # or udp
syslog('info', "test\n");

Any idea on how to get stream at work? Or to get rid of the prefix?

I am not sure about 'stream' and do not have root access on my Solaris ISP
to check logs, but for Linux where I have a variable to indicate whether
it should log I have:

# grouped with other variable settings
# Flag for Unix syslog, 1 (yes), 0 (no)
BEGIN { $main::syslog = 1; }


# farther down...
# Name of this script
if ($0 =~ m|/([^/]+)$|) { $id = $1; } else { $id = $0; }

# Initialize local system log (unix)
BEGIN {
if ($main::syslog) {
use Sys::Syslog qw:)DEFAULT setlogsock);
setlogsock 'unix' || die "Can't setlogsock";
}
}

sub mylog {
my $msg = shift;
chomp $msg;
if ($syslog) { syslog('info',"$id\[$$]:$msg"); closelog(); }
# along w/other routines to optionally log to file, etc.
}
 
L

Loic Minier

* David Efflandt said:
use Sys::Syslog qw:)DEFAULT setlogsock);
setlogsock 'unix' || die "Can't setlogsock";

'unix' won't work with the standard Solaris syslogd since it doesn't
listen on an unix socket, but your post is particularly helpful because
I just realized that syslog-ng can probably create an unix socket!
I will try this on monday, when I will have access to the Solaris
boxes again. I'll keep the group informed.

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top