powerman has asked for the wisdom of the Perl Monks concerning the following question:

I want to use syslog for logging all messages from my CGI and CRON scripts.
But I don't want to send these messages to system's syslog (/dev/log) because these CGI/CRON scripts should be installed on hosting where I don't have access to system logs.
I want to send these messages to my own /dev/log -like unix socket. (I will start syslog-like daemon (socklog+svlogd) to listen on this socket.)

So, the question is: how I can configure Sys::Syslog to send my messages to my unix socket "/var/www/blah/log" instead of "/dev/log"?

I expected this code to work:
use Sys::Syslog qw(:DEFAULT setlogsock); setlogsock("stream", "/var/www/blah/log") or die $!; openlog "onliner", "pid", "user" or die $!; syslog "warning", "test=%d", 15;
but it isn't working. I've found only one dirty hack to do this (after looking at Sys::Syslog source):
use Sys::Syslog qw(:DEFAULT setlogsock); sub Sys::Syslog::_PATH_LOG {"/var/www/blah/log"} setlogsock("unix") or die "setlogsock: $!"; openlog "onliner", "pid", "user" or die "openlog: $!"; syslog "warning", "test: %d", 15;
Is there exists not so ugly way?

Replies are listed 'Best First'.
Re: Sys::Syslog to my file
by PodMaster (Abbot) on May 23, 2004 at 13:12 UTC
    but it isn't working
    How?
    Is there exists not so ugly way?
    I would think the documented way would be the not so ugly way. If that's not working for you, and you've got the latest version of the module, then contact the maintainer and file a bug report (or just fix it).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      $ perl -e 'use Sys::Syslog qw(:DEFAULT setlogsock); setlogsock "stream", ".lib/log"; openlog "onliner", "pid", "user"; syslog "warning", "test=%d", 15;'
      stream /dev/conslog is not writable at -e line 1
      no connection to syslog available at -e line 1

      $ perl -e 'use Sys::Syslog qw(:DEFAULT setlogsock); setlogsock "unix", ".lib/log"; openlog "onliner", "pid", "user"; syslog "warning", "test=%d", 15;'
      unix passed to setlogsock, but path not available at -e line 1

      $ perl -e 'use Sys::Syslog qw(:DEFAULT setlogsock); sub Sys::Syslog::_PATH_LOG {".lib/log"} setlogsock "unix"; openlog "onliner", "pid", "user"; syslog "warning", "test=%d", 15;'
      no errors, message sent to .lib/log socket