modperl-apache_syslogging_under_modperl

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: Lance Uyehara <lance@verniernetworks.com>
From: Paul Lindner <lindner@inuus.com>
Subject: Re: PerlWarn and syslog
Date: Thu, 6 Dec 2001 14:16:32 -0800

On Thu, Dec 06, 2001 at 02:11:28PM -0800, Lance Uyehara wrote:
> I am using apache+mod_perl and have:
> 
> ErrorLog syslog
> PerlWarn On
> 
> However the warning don't come out. If I change to "ErrorLog
> /var/log/logfile" or something similar then the warning start appearing. How
> do I get the warnings when syslog is used?

I've seen various problems with Apache's built in syslog under
mod_perl.  The solution that I've been using lately is:

ErrorLog "| logger -p local3.debug"


If you just print to STDERR you might want to look at Apage::LogSTDERR
on CPAN.

===

To: Lance Uyehara <lance@verniernetworks.com>
From: Ged Haywood <ged@www2.jubileegroup.co.uk>
Subject: Re: PerlWarn and syslog
Date: Thu, 6 Dec 2001 22:27:45 +0000 (GMT)

Hi there,

On Thu, 6 Dec 2001, Lance Uyehara wrote:

> ErrorLog syslog

Are you sure you want to do this?

> How do I get the warnings when syslog is used?

There are some tips in Stas Bekman's new book, not yet published
(you'll have to become a reviwer:) and you will find some help in the
guide -- http://perl.apache.org/guide/porting.html#Apache_and_syslog


===

To: Ged Haywood <ged@www2.jubileegroup.co.uk>
From: Stas Bekman <stas@stason.org>
Subject: Re: PerlWarn and syslog
Date: Fri, 07 Dec 2001 11:22:30 +0800

Ged Haywood wrote:

> Hi there,
> 
> On Thu, 6 Dec 2001, Lance Uyehara wrote:
> 
> 
>>ErrorLog syslog
>>
> 
> Are you sure you want to do this?
> 
> 
>>How do I get the warnings when syslog is used?
>>
> 
> There are some tips in Stas Bekman's new book, not yet published
> (you'll have to become a reviwer:) and you will find some help in the
> guide -- http://perl.apache.org/guide/porting.html#Apache_and_syslog


Too many people suggested that we plunge the syslog section because of 
its slowness and unreliability. You should use log_spread instead if you 
need to collect logs from many machines.

Since this section ss probably going away, here it is:

The syslog solution can be implemented using the following
configuration:

   LogFormat "%h %l %u %t \"%r\" %>s %b" common
   CustomLog "| /usr/local/apache/bin/syslogger.pl hostnameX" common

where a simple I<syslogger.pl> can look like this:

   syslogger.pl
   ------------
   #!/usr/bin/perl
   use Sys::Syslog qw(:DEFAULT setlogsock);

   my $hostname = shift || 'localhost';
   my $priority = 'ndelay'; # open the connection immediately
   my $facility = 'local0'; # one of local0..local7
   my $priority = 'info';   # debug|info|notice|warning|err...

   setlogsock 'unix';
   openlog $hostname, $priority, $facility;
   while (<>) {
       chomp;
       syslog $priority, $_;
   }
   closelog;

The syslog utility needs to know the facility to work with and the
logging level. We will use C<local0>, one of the special logging
facilities reserved for local usage (eight local facilities are
available: local0 to local7). We will use the C<info> priority level
(again one of eight possible levels: I<debug>, I<info>, I<notice>,
I<warning>, I<err>, I<crit>, I<alert>, I<emerg>).

Now make the syslog utility on the master machine (where all logs are
to be stored) log all messages coming from facility C<local0> with
logging level C<info> to a file of our choice. This is achieved by
editing the I</etc/syslog.conf> file. For example:

   local0.info /var/log/web/access_log

All other machines forward their logs from facility C<local0> to the
central machine, therefore on all but the master machine we add the
forwarding directive to the I</etc/syslog.conf> file (assuming that
the master machine's hostname is C<masterhost>):

   local0.info @masterhost

We must restart the syslogd(8) daemon or send it the C<-HUP> kill
signal for the changes to take effect before the logger can be used.


===

To: "Stas Bekman" <stas@stason.org>,
From: "Lance Uyehara" <lance@verniernetworks.com>
Subject: Re: PerlWarn and syslog
Date: Fri, 7 Dec 2001 08:09:35 -0800

> Since this section ss probably going away, here it is:
>
> The syslog solution can be implemented using the following
> configuration:
>
>    LogFormat "%h %l %u %t \"%r\" %>s %b" common
>    CustomLog "| /usr/local/apache/bin/syslogger.pl hostnameX" common
>
> where a simple I<syslogger.pl> can look like this:
>
>    syslogger.pl
>    ------------
>    #!/usr/bin/perl
>    use Sys::Syslog qw(:DEFAULT setlogsock);
>
>    my $hostname = shift || 'localhost';
>    my $priority = 'ndelay'; # open the connection immediately
>    my $facility = 'local0'; # one of local0..local7
>    my $priority = 'info';   # debug|info|notice|warning|err...
>
>    setlogsock 'unix';
>    openlog $hostname, $priority, $facility;
>    while (<>) {
>        chomp;
>        syslog $priority, $_;
>    }
>    closelog;

[snip]
Hmm. Why is priority redefined? Seems like you'll lose your ndelay param. I
think you mean to do something like:

    my $hostname = shift || 'localhost';
    my $options = 'ndelay'; # open the connection immediately
    my $facility = 'local0'; # one of local0..local7

    my $priority = 'info';   # debug|info|notice|warning|err...
    setlogsock 'unix';
    openlog $hostname, $options, $facility;

    while (<>) {
        chomp;
        syslog $severity, $_;
    }
    closelog;

The problem with this solution is all logs from apache will now have the
same priority, and they were made up by me. I'd like to keep the same
priority which apache set.

Thanks for all the help so far. I appreciate the quick responses.

-Lance




===

To: Geoffrey Young <geoff@modperlcookbook.org>
From: Paul Lindner <lindner@inuus.com>
Subject: Re: PerlWarn and syslog
Date: Fri, 21 Dec 2001 11:05:19 -0800

On Thu, Dec 20, 2001 at 01:59:18PM -0500, Geoffrey Young wrote:
> 
> > > If you just print to STDERR you might want to look at Apage::LogSTDERR
> > > on CPAN.
> > 
> > I took at look on CPAN and was unable to find this module or any reference
> > to it. Any idea if it has been merged into some other module or if it has
> > just gone away?
> 
> over the years, the folks at critical path keep teasing with talk of
> releasing Apache::LogSTDERR, but I don't think anyone outside of CP
> (Doug, Brian, Paul) has actually seen it :)

My apologies.  I never realized that it had never been released.  I'm
volunteering to maintain it, so I'll publish it under my CPAN id
soon..

For now you can visit:

  http://www.modperlcookbook.org/code.html 

and pick up a copy.

Enjoy!

===

To: <lindner@inuus.com>, "Geoffrey Young"
<geoff@modperlcookbook.org>,
From: "Lance Uyehara" <lance@verniernetworks.com>
Subject: Re: PerlWarn and syslog
Date: Fri, 21 Dec 2001 11:25:42 -0800

> On Thu, Dec 20, 2001 at 01:59:18PM -0500, Geoffrey Young wrote:
> >
> > > > If you just print to STDERR you might want to look at
Apage::LogSTDERR
> > > > on CPAN.
> > >
> > > I took at look on CPAN and was unable to find this module or any
reference
> > > to it. Any idea if it has been merged into some other module or if it
has
> > > just gone away?
> >
> > over the years, the folks at critical path keep teasing with talk of
> > releasing Apache::LogSTDERR, but I don't think anyone outside of CP
> > (Doug, Brian, Paul) has actually seen it :)
>
> My apologies.  I never realized that it had never been released.  I'm
> volunteering to maintain it, so I'll publish it under my CPAN id
> soon..
>
> For now you can visit:
>
>   http://www.modperlcookbook.org/code.html
>
> and pick up a copy.

Thanks for the info. I've taken the various suggestions and am going with
Errorlog "| /some/perl/script.pl". Thanks to all who responded.

I really appreciate the help.
-Lance

===




the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu