1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Rep Power

    Syslog Implementation using TCP

    I'm trying to use TCP protocol to perform both local and Remote logging. Here's the code:-

    use strict;
    use warnings;
    use diagnostics;
    use Sys::Syslog;
    use Sys::Syslog qw(:standard :macros);
    use Sys::Syslog qw(: DEFAULT setlogsock);
    my $program="test.pl";
    my $host = "xx.xxx.xx.xx";
    openlog($program, "ndelay,pid", "local3");
    syslog('debug','%s', 'Test case');

    print("Log has added to local log");

    setlogsock('tcp'); --line 14
    #setlogsock({ type => 'tcp', host => $host });
    $Sys::Syslog::host = $host;
    openlog($program, 'ndelay,pid','user');
    syslog('err', 'test case');

    print("\nLog has added to Remote log file using TCP.\n");

    The program is able to log the data in both local and remote server but the output provides following error message:-

    tcp passed to setlogsock, but tcp service unavailable at test.pl line 14
    Log has added to local log.
    Log has added to Remote log file using TCP.

    Can anyone please provide inputs to solve this problem.

    Thanks in advance.
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    in da kitchen ...
    Rep Power
    comment out 14, and uncomment 15 and see what happens

    a quick glance indicates that there needs to be an ip or hostname passed to the setlogsock call (might default to localhost)

    What machine are you running this on?
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones

    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...

IMN logo majestic logo threadwatch logo seochat tools logo