trying to "use Sys::Syslog" but I get nothing ...

K

Karen Wieprecht

I'm trying to get some data sent into the system log after processing it
with a perl program. the text processing works great, and if I send to
stdout, the messages come out as they are processed. However, I'm trying
to
send the messages to the system log with "use Sys::Syslog" and I am not
getting anything ...

1. I'm using perl 5.6
2. syslog.conf is configured to show *.notice
3. I have seen examples with different flavors of quotes ( " .vs. ') in
the setlogsock, openlog, and syslog commands. I tried both ways with no
effect.

Code snippit (not the full program):

use Sys::Syslog qw:)DEFAULT setlogsock);
setlogsock ("unix");
openlog ("audit", "ndelay,nowait", "local5");

while ( <> ) {
chomp;
$PRINT_STRING = $_;
syslog ("notice", " %s\n",$PRINT_STRING) ;
}
closelog ();


I never get a syntax error, but I don't get any of the messages into the
system log either . I can't get the syslog command to DO anything. the
syntax looks right compared to many samples of the code I've seen ... maybe
I'm missing something?


Any ideas? Help would be most appreciated.

Thanks,

Karen Wieprecht
 
A

Anno Siegel

Karen Wieprecht said:
I'm trying to get some data sent into the system log after processing it
with a perl program. the text processing works great, and if I send to
stdout, the messages come out as they are processed. However, I'm trying
to
send the messages to the system log with "use Sys::Syslog" and I am not
getting anything ...

1. I'm using perl 5.6
2. syslog.conf is configured to show *.notice
3. I have seen examples with different flavors of quotes ( " .vs. ') in
the setlogsock, openlog, and syslog commands. I tried both ways with no
effect.

Code snippit (not the full program):

use Sys::Syslog qw:)DEFAULT setlogsock);
setlogsock ("unix");
openlog ("audit", "ndelay,nowait", "local5");

while ( <> ) {
chomp;
$PRINT_STRING = $_;
syslog ("notice", " %s\n",$PRINT_STRING) ;
}
closelog ();

That code (or a close-enough variant) works for me as expected, so there's
no telling what is going wrong in your setup. At least two of the functions
you are using are documented as returning false on error, syslog() probably
does too. Check the return values and see what fails.

Anno
 
T

terry l. ridder

I'm trying to get some data sent into the system log after processing it
with a perl program. the text processing works great, and if I send to
stdout, the messages come out as they are processed. However, I'm trying
to send the messages to the system log with "use Sys::Syslog" and I am not
getting anything ...

1. I'm using perl 5.6
2. syslog.conf is configured to show *.notice

which log file are *.notice msgs logged?
3. I have seen examples with different flavors of quotes ( " .vs. ') in
the setlogsock, openlog, and syslog commands. I tried both ways with no
effect.

Code snippit (not the full program):

use Sys::Syslog qw:)DEFAULT setlogsock);
setlogsock ("unix");
openlog ("audit", "ndelay,nowait", "local5");

while ( <> ) {
chomp;
$PRINT_STRING = $_;
syslog ("notice", " %s\n",$PRINT_STRING) ;
}
closelog ();

works for me. msgs are logged to /var/log/messages.
Jan 25 00:29:11 johann audit: this is a test
I never get a syntax error, but I don't get any of the messages into the
system log either . I can't get the syslog command to DO anything. the
syntax looks right compared to many samples of the code I've seen ... maybe
I'm missing something?

best guess would be:
0. the msgs are being logged but not where you think/want them logged.
1. there is a problem with /etc/syslog.conf.
 
K

Karen Wieprecht

which log file are *.notice msgs logged?

They all go to /var/adm/SYSLOG.

best guess would be:
0. the msgs are being logged but not where you think/want them logged.
1. there is a problem with /etc/syslog.conf.

I tested
logger -p local5.notice "this is a test"
and it came out exactly where I expected it.


I also tested the return values of openlog (it was 1) and each syslog call
with my various strings, and I got the following values :
53,58,60,62,65,75

But I'm still not getting anything in syslog...

Anyone know if I need to have the options in all caps or if the quotes
should be single rather than double? This is very frustrating ...
 
A

Anno Siegel

Karen Wieprecht said:
They all go to /var/adm/SYSLOG.



I tested
logger -p local5.notice "this is a test"
and it came out exactly where I expected it.


I also tested the return values of openlog (it was 1) and each syslog call
with my various strings, and I got the following values :
53,58,60,62,65,75

That leaves the call to setlogsock, though for me it dies with an invalid
argument. Anyway, check its return value too, also try leaving it out
altogether.
But I'm still not getting anything in syslog...

Anyone know if I need to have the options in all caps

Not for me. Consult your local "man syslogd".

or if the quotes
should be single rather than double?

The type of quotes doesn't matter. Only Perl sees them, not syslog.
This is very frustrating ...

Your main problem is that no-one can reproduce what you're seeing. It's
hard to debug a problem you don't have. What version of Perl (perl -v),
and what version of Sys::Syslog
(perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION')
are you running?

Anno
 
T

terry l. ridder

They all go to /var/adm/SYSLOG.

on my computers they end up in /var/log/messages
that depends on /etc/syslog.conf
I tested
logger -p local5.notice "this is a test"
and it came out exactly where I expected it.



I also tested the return values of openlog (it was 1) and each syslog call
with my various strings, and I got the following values :
53,58,60,62,65,75

under perl 5.6 syslog returned the number of bytes written to the log.
But I'm still not getting anything in syslog...

i thought that it may be a quirk in perl 5.6 so i fired up an old
computer that has perl 5.6 installed and tired the code snippet you
provided. it worked. the tests ended up in /var/log/messages.

Jan 25 12:18:22 strauss audit: this is a test
Jan 25 12:18:33 strauss audit: this is also a test.
Jan 25 12:18:40 strauss audit: this is a 3rd test.
Anyone know if I need to have the options in all caps or if the quotes
should be single rather than double? This is very frustrating ...

at this point i fall back to my original guess:
0. the msgs are being logged but not where you think/want them logged.
 
K

Karen Wieprecht

Anno,

Thanks for trying to help. the test for which version if Sys::Syslog was
very cool, I'll keep that one handy. Don't know if this helps or not, but
the output from

perl -v
is 5.6.1
perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
0.01

Let me know if the version has known problems ...

Karen Wieprecht
 
A

Anno Siegel

Karen Wieprecht said:
Anno,

Thanks for trying to help. the test for which version if Sys::Syslog was
very cool, I'll keep that one handy. Don't know if this helps or not, but
the output from

perl -v
is 5.6.1
perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
0.01

Let me know if the version has known problems ...

No idea, but both perl and Sys::Syslog are ancient. If upgrading is an
option at all, do that. Chances are, this and similar future problems
will go away.

Anno
 
T

terry l. ridder

Anno,

Thanks for trying to help. the test for which version if Sys::Syslog was
very cool, I'll keep that one handy. Don't know if this helps or not, but
the output from

perl -v
is 5.6.1
perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
0.01

those are the same versions that i tested on the old computer i fired up.
the code snippet works on that computer.
 
T

terry l. ridder

No idea, but both perl and Sys::Syslog are ancient. If upgrading is an
option at all, do that. Chances are, this and similar future problems
will go away.

i agree that they are ancient, but they do work.
i tested the exact code snippet on an old computer running debian linux
distribution.

This is perl, v5.6.1 built for i386-linux
perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION'
0.01

the problem does not appear to be with perl.
i still am of the opinion that the msgs are being logged just not where
they are supposed to be logged.
 
A

Anno Siegel

terry l. ridder said:
i agree that they are ancient, but they do work.
i tested the exact code snippet on an old computer running debian linux
distribution.

This is perl, v5.6.1 built for i386-linux
perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION'
0.01

the problem does not appear to be with perl.
i still am of the opinion that the msgs are being logged just not where
they are supposed to be logged.

I would agree if we hadn't this from the OP

I tested
logger -p local5.notice "this is a test"
and it came out exactly where I expected it.

Anno
 
K

Karen Wieprecht

so instead of
setlogsock ("unix");
it would be
setlogsock ("stream");


Yep, I tried that and got an error instead of no output (the system didn't
seem to like setlogsock ("stream"); I'm trying to get a hold of the
person who built perl for Irix to see if this function should be supported.
Waiting for an answer ...

THanks

-Karen Wieprecht
 

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,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top