Sys::Syslog under Solaris

Discussion in 'Perl Misc' started by Loic Minier, Mar 5, 2004.

  1. Loic Minier

    Loic Minier Guest

    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,

    --
    Loïc Minier <>
    Loic Minier, Mar 5, 2004
    #1
    1. Advertising

  2. On Fri, 5 Mar 2004 14:09:51 +0100, Loic Minier <> wrote:
    > 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.
    }

    --
    David Efflandt - All spam ignored http://www.de-srv.com/
    David Efflandt, Mar 5, 2004
    #2
    1. Advertising

  3. Loic Minier

    Loic Minier Guest

    * David Efflandt <>,
    Fri, 5 Mar 2004 19:31:02 +0000 (UTC):
    > 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,

    --
    Loïc Minier <>
    Loic Minier, Mar 6, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    6,060
    Chris Uppal
    Jun 20, 2006
  2. Thomas Glanzmann

    Sys::Syslog issue on Solaris 9 with perl-5.8.2

    Thomas Glanzmann, Jan 10, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    170
    Thomas Glanzmann
    Jan 10, 2004
  3. leroy isaac
    Replies:
    1
    Views:
    481
    James Willmore
    Oct 29, 2004
  4. A
    Replies:
    0
    Views:
    115
  5. Bad Dog
    Replies:
    0
    Views:
    234
    Bad Dog
    Aug 9, 2007
Loading...

Share This Page