Operating System - Linux
1752622 Members
4304 Online
108788 Solutions
New Discussion юеВ

perl Sys::Syslog logs fqdn

 
John Kittel
Trusted Contributor

perl Sys::Syslog logs fqdn

All previous existing entries in my syslog.log have the format:

MMM DD HH:MM:SS LF:name tag: message

where LF are level and facility ( I use -v in syslog options), and name = simple host name.

And, if I use logger to log a message, I get the same format.

BUT, if I use a perl program, the simple host name becomes a fully qualified host.domain-name.

Is there a way to use the perl module Sys::Syslog to log messages with only the simple host name, not the fully qualified name?
(I'm looking, and trying various things, but don't see a way. I guess I could use system or backticks to call logger...)

Thanks.
4 REPLIES 4
John Kittel
Trusted Contributor

Re: perl Sys::Syslog logs fqdn

Oh, I'm using Sys::Syslog (version 0.01). I see there are newer versions available. I haven't checked if newer versions address this...
A. Clay Stephenson
Acclaimed Contributor

Re: perl Sys::Syslog logs fqdn

I've never used this module but one thing jumps out at me. When you invoke openlog what are you using as $ident? ... and did you, in fact, call openlog before using the syslog function?
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: perl Sys::Syslog logs fqdn

Hi:

I don't think that you can control the logging (but then why?). WHen you extract your log, simply snip/substitute off the domain name.

# echo "server.in.domain"|perl -nle 'print $1 if /(.+?)(\..+)/'

Regards!

...JRF...
John Kittel
Trusted Contributor

Re: perl Sys::Syslog logs fqdn

Thanks, guys.

Clay, I tried using openlog, and without using openlog. Using openlog, with $ident = simple hostname, I get the same format

MMM DD HH:MM:SS LF:name tag: message

where name = fully qualified name, and tag = the simple host name that I put in $ident.

JRF, the syslog is forwarded to another system managed by someone else, who is creating reports from it. I was just in the initial stages of developing this, and thought it would be simpler for them if the messages all had the same format.