You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Beau E. Cox" <be...@beaucox.com> on 2002/12/05 07:45:26 UTC

[mp2] LogHandler configuration problems

Well Stas, you asked for it... :)

-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:

   LogHandler configuration problem. In the tests below
   I start out with the LogHandler configuration in the documentation
   and keep 'trimming' it down until it works. I'm almost
   (not 100%) sure the problem has something with the way I'm
   configured, but, being a neeeeewwwwwwbbbbbiiiiieeee, I can't
   see it. This is low-priority; I have it working fine, I'm
   just trying to understand what's going on.

   Oh, almost forgot, ALL files are set to mywebuser:mywebgroup
   as defined in the User/Group httpd.conf directives.

   A. startup.pl (remains the same for all tests below)

    use Apache2 ();
    use lib qw(/srv/www/conf/perl);
    use ModPerl::Util (); #for CORE::GLOBAL::exit
    use Apache::RequestRec ();
    use Apache::RequestIO ();
    use Apache::RequestUtil ();
    use Apache::Server ();
    use Apache::ServerUtil ();
    use Apache::Connection ();
    use Apache::Log ();
    use APR::Table ();
    use ModPerl::Registry ();
    use Apache::Const -compile => ':common';
    use APR::Const -compile => ':common';
    1;

   B. 'default' page setting in httpd.conf (same for all)

    DirectoryIndex index.html index.html.var

   C. my log handler (same for all)

    package MyApache::FileLogger;

    use strict;
    use warnings;

    use Apache::RequestRec ();
    use Apache::Connection ();
    use Fcntl qw(:flock);

    use Apache::Const -compile => qw(OK DECLINED);

    sub handler
    {
    	my $r = shift;

    	my $entry = sprintf qq(%s [%s] "%s" %d %d\n),
    		$r->connection->remote_ip, scalar(localtime),
    		$r->uri, $r->status, $r->bytes_sent;

    	my $log_path = Apache::server_root_relative($r->pool,
    		"logs/filelogger.log");
    	open my $fh, ">>$log_path" or die "can't open $log_path: $!";
    	flock $fh, LOCK_EX;
    	print $fh $entry;
    	close $fh;

    	return Apache::OK;
    }
    1;

   C1. /perl/rocks.html

    #!/usr/bin/perl
    print "Content-type: text/html\n\n";
    print "<h3>mod_perl 2.0 rocks!</h3>\n";

   D. test 1

    ---httpd.conf---

    LoadModule perl_module modules/mod_perl.so
    PerlRequire "/srv/www/conf/perl/startup.pl"

    #-------------------mod_perl 2.0 rocks
test---------------------------------
    Alias /perl/ /srv/www/conf/perl/
    <Location /perl/>
    	SetHandler perl-script
    	PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
    </Location>


#-------------------MyApache-FileLogger-------------------------------------
    <Location />
    	SetHandler perl-script
    	PerlResponseHandler ModPerl::Registry
    	PerlLogHandler MyApache::FileLogger
    	Options +ExecCGI
    </Location>

    ---log---

    ::1 [Wed Dec  4 19:58:13 2002] "/" 404 266
    ::1 [Wed Dec  4 19:58:24 2002] "/index.html" 403 280
    ::1 [Wed Dec  4 19:58:45 2002] "/perl/rocks.html" 200 29

    localhost  -> not found (DirectoryIndex not followed)
	localhost/index.html -> premission nixed
	localhost/perl/rocks.html -> OK

   E. test 2

    ---httpd.conf---

    LoadModule perl_module modules/mod_perl.so
    PerlRequire "/srv/www/conf/perl/startup.pl"

    #-------------------mod_perl 2.0 rocks
test---------------------------------
    Alias /perl/ /srv/www/conf/perl/
    <Location /perl/>
    	SetHandler perl-script
    	PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
    </Location>


#-------------------MyApache-FileLogger-------------------------------------
    <Location />
    	SetHandler perl-script
    	PerlResponseHandler ModPerl::Registry
    	PerlLogHandler MyApache::FileLogger
    #	Options +ExecCGI
    </Location>

    ---log---

    ::1 [Wed Dec  4 20:12:43 2002] "/" 404 266
    ::1 [Wed Dec  4 20:12:49 2002] "/index.html" 403 280
    ::1 [Wed Dec  4 20:12:59 2002] "/perl/rocks.html" 200 29

   F. test 3

    ---httpd.conf---

    LoadModule perl_module modules/mod_perl.so
    PerlRequire "/srv/www/conf/perl/startup.pl"

    #-------------------mod_perl 2.0 rocks
test---------------------------------
    Alias /perl/ /srv/www/conf/perl/
    <Location /perl/>
    	SetHandler perl-script
    	PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
    </Location>


#-------------------MyApache-FileLogger-------------------------------------
    <Location />
    	SetHandler perl-script
    #  	PerlResponseHandler ModPerl::Registry
    	PerlLogHandler MyApache::FileLogger
    #	Options +ExecCGI
    </Location>

    ---log---

    ::1 [Wed Dec  4 20:17:30 2002] "/" 404 266
    ::1 [Wed Dec  4 20:17:47 2002] "/index.html" 200 1495
    ::1 [Wed Dec  4 20:17:47 2002] "/apache_pb.gif" 200 2326
    ::1 [Wed Dec  4 20:17:56 2002] "/perl/rocks.html" 200 29

	well, some progress...

   G. test 4

    ---httpd.conf---

    LoadModule perl_module modules/mod_perl.so
    PerlRequire "/srv/www/conf/perl/startup.pl"

    #-------------------mod_perl 2.0 rocks
test---------------------------------
    Alias /perl/ /srv/www/conf/perl/
    <Location /perl/>
    	SetHandler perl-script
    	PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
    </Location>


#-------------------MyApache-FileLogger-------------------------------------
    <Location />
    #	SetHandler perl-script
    #  	PerlResponseHandler ModPerl::Registry
    	PerlLogHandler MyApache::FileLogger
    #	Options +ExecCGI
    </Location>

    ---log---

    ::1 [Wed Dec  4 20:22:33 2002] "/index.html" 200 1495
    ::1 [Wed Dec  4 20:22:33 2002] "/apache_pb.gif" 304 0
    ::1 [Wed Dec  4 20:22:53 2002] "/perl/rocks.html" 200 29
    ::1 [Wed Dec  4 20:24:07 2002] "/index.html" 200 1495
    ::1 [Wed Dec  4 20:24:07 2002] "/apache_pb.gif" 304 0

	ALL OK

   H. test 5

    ---httpd.conf---

    LoadModule perl_module modules/mod_perl.so
    PerlRequire "/srv/www/conf/perl/startup.pl"

    #-------------------mod_perl 2.0 rocks
test---------------------------------
    Alias /perl/ /srv/www/conf/perl/
    <Location /perl/>
    	SetHandler perl-script
    	PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
    </Location>


#-------------------MyApache-FileLogger-------------------------------------
    #<Location />
    #	SetHandler perl-script
    #  	PerlResponseHandler ModPerl::Registry
    	PerlLogHandler MyApache::FileLogger
    #	Options +ExecCGI
    #</Location>

    ---log---

    ::1 [Wed Dec  4 20:27:48 2002] "/index.html" 200 1495
    ::1 [Wed Dec  4 20:27:48 2002] "/apache_pb.gif" 304 0
    ::1 [Wed Dec  4 20:28:00 2002] "/perl/rocks.html" 200 29
    ::1 [Wed Dec  4 20:28:58 2002] "/index.html" 200 1495
    ::1 [Wed Dec  4 20:28:58 2002] "/apache_pb.gif" 304 0

	ALL OK

2. Used Components and their Configuration:

*** using lib/Apache/BuildConfig.pm
*** Makefile.PL options:
  MP_AP_PREFIX    => /usr/local/apache2
  MP_GENERATE_XS  => 1
  MP_INST_APACHE2 => 1
  MP_LIBNAME      => mod_perl
  MP_USE_DSO      => 1
  MP_USE_STATIC   => 1


*** /usr/local/apache2/sbin/httpd -V
Server version: Apache/2.0.43
Server built:   Dec  4 2002 01:07:19
Server's Module Magic Number: 20020903:0
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/worker"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/httpd/mime.types"
 -D SERVER_CONFIG_FILE="/etc/httpd/httpd.conf"


*** /usr/bin/perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.19, archname=i586-linux-thread-multi
    uname='linux amdsim5 2.4.19 #1 wed mar 27 13:57:05 utc 2002 i686 unknown
'




config_args='-ds -e -Dprefix=/usr -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_g
dbm -Duseshrplib=true'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags
='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FIL
E_OFFSET_BITS=64',
    optimize='-O3 --pipe',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing'
    ccversion='', gccversion='3.2', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =''
    libpth=/lib /usr/lib /usr/local/lib
    libs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i586-linux-thread-multi
/CORE'
    cccdlflags='-fPIC', lddlflags='-shared'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
  Built under linux
  Compiled at Oct  8 2002 16:55:42
  %ENV:
    PERL_LWP_USE_HTTP_10="1"
  @INC:
    /usr/lib/perl5/5.8.0/i586-linux-thread-multi
    /usr/lib/perl5/5.8.0
    /usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    .


3. This is the core dump trace: (if you get a core dump):

  [CORE TRACE COMES HERE]

This report was generated by t/REPORT on Thu Dec  5 05:52:35 2002 GMT.

-------------8<---------- End Bug Report --------------8<----------

Note: Complete the rest of the details and post this bug report to
dev <at> perl.apache.org. To subscribe to the list send an empty
email to dev-subscribe@perl.apache.org.



Re: [mp2] LogHandler configuration problems

Posted by Stas Bekman <st...@stason.org>.
Beau E. Cox wrote:
> Hi Stas -
> 
> ...look at the error log...
> 
> For the first test, which my logger reported:
> 
> ::1 [Wed Dec  4 19:58:13 2002] "/" 404 266
> ::1 [Wed Dec  4 19:58:24 2002] "/index.html" 403 280
> ::1 [Wed Dec  4 19:58:45 2002] "/perl/rocks.html" 200 29
> 
> The error log reported:
> 
> [Wed Dec 04 19:58:13 2002] [error] [client ::1]
>   Attempt to serve directory: /srv/www/htdocs/
> [Wed Dec 04 19:58:24 2002] [error]
>   file permissions deny server execution/srv/www/htdocs/index.html
> 
> I don't see that these error_log entries "...revealed the
> problem right away, from the first test..." To me, newbie that
> I am, they give abount the same information that my logger gave...

bummer ;) I was sure that registry will complain in the logs, but forgot 
that Apache got on its way. So you were right and I wrong ;) Glad that 
you've figured it out.

> OK, I'll relax. The secret is to read and test more before crying
> wolf

you'd be surprised how many times i've cried wolf myself... even did 
that, this morning ;)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


RE: [mp2] LogHandler configuration problems

Posted by "Beau E. Cox" <be...@beaucox.com>.
Hi Stas -

...look at the error log...

For the first test, which my logger reported:

::1 [Wed Dec  4 19:58:13 2002] "/" 404 266
::1 [Wed Dec  4 19:58:24 2002] "/index.html" 403 280
::1 [Wed Dec  4 19:58:45 2002] "/perl/rocks.html" 200 29

The error log reported:

[Wed Dec 04 19:58:13 2002] [error] [client ::1]
  Attempt to serve directory: /srv/www/htdocs/
[Wed Dec 04 19:58:24 2002] [error]
  file permissions deny server execution/srv/www/htdocs/index.html

I don't see that these error_log entries "...revealed the
problem right away, from the first test..." To me, newbie that
I am, they give abount the same information that my logger gave...

OK, I'll relax. The secret is to read and test more before crying
wolf,

Aloha => Beau.

-----Original Message-----
From: Stas Bekman [mailto:stas@stason.org]
Sent: Wednesday, December 04, 2002 9:23 PM
To: Beau E. Cox
Cc: Modperl
Subject: Re: [mp2] LogHandler configuration problems


Beau E. Cox wrote:
> Well Stas, you asked for it... :)
[...]
>     #-------------------mod_perl 2.0 rocks
> test---------------------------------
>     Alias /perl/ /srv/www/conf/perl/
>     <Location /perl/>
>     	SetHandler perl-script
>     	PerlResponseHandler ModPerl::Registry
>         PerlOptions +ParseHeaders
>         Options +ExecCGI
>     </Location>
>
>
>
#-------------------MyApache-FileLogger-------------------------------------
>     <Location />
>     	SetHandler perl-script
>     	PerlResponseHandler ModPerl::Registry
>     	PerlLogHandler MyApache::FileLogger
>     	Options +ExecCGI
>     </Location>

As you have figured out by trial and error, if you wanted the logger to
work for everything you just needed to add:

 >     <Location />
 >     	PerlLogHandler MyApache::FileLogger
 >     </Location>

what you originally did, is assigned ModPerl::Registry to serve
everything on the server, but fed it with html and images, forgetting
that it requires a Perl diet. Since you've repeated many times that you
are a newbie, I'll forgive you ;) But if you weren't a newbie and you
didn't remember to check the error_log file, I'd say: "shame on you" :)
As the latter would have revealed the problem right away, from the first
test.

Notice that my example configuration is correct since it demonstrates
the use of a logger for a particular sub-section of the site that
*happens* to be served by the ModPerl::Registry handler. Perhaps that
example needs some extra notes to avoid this kind of confusion in the
future. I'll add a note.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com




Re: [mp2] LogHandler configuration problems

Posted by Stas Bekman <st...@stason.org>.
Beau E. Cox wrote:
> Well Stas, you asked for it... :)
[...]
>     #-------------------mod_perl 2.0 rocks
> test---------------------------------
>     Alias /perl/ /srv/www/conf/perl/
>     <Location /perl/>
>     	SetHandler perl-script
>     	PerlResponseHandler ModPerl::Registry
>         PerlOptions +ParseHeaders
>         Options +ExecCGI
>     </Location>
> 
> 
> #-------------------MyApache-FileLogger-------------------------------------
>     <Location />
>     	SetHandler perl-script
>     	PerlResponseHandler ModPerl::Registry
>     	PerlLogHandler MyApache::FileLogger
>     	Options +ExecCGI
>     </Location>

As you have figured out by trial and error, if you wanted the logger to 
work for everything you just needed to add:

 >     <Location />
 >     	PerlLogHandler MyApache::FileLogger
 >     </Location>

what you originally did, is assigned ModPerl::Registry to serve 
everything on the server, but fed it with html and images, forgetting 
that it requires a Perl diet. Since you've repeated many times that you 
are a newbie, I'll forgive you ;) But if you weren't a newbie and you 
didn't remember to check the error_log file, I'd say: "shame on you" :) 
As the latter would have revealed the problem right away, from the first 
test.

Notice that my example configuration is correct since it demonstrates 
the use of a logger for a particular sub-section of the site that 
*happens* to be served by the ModPerl::Registry handler. Perhaps that 
example needs some extra notes to avoid this kind of confusion in the 
future. I'll add a note.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com