You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Richard Chen <ch...@snet.net> on 2001/05/26 15:23:17 UTC
modify url in web log via PerlLogHandler
Is it possible to modify the logged url in the usual
modperl weblog via PerlLogHandler? I have tried this and
it does not seem to work:
$ cat Apache/MyLog.pm
package Apache::MyLog;
use Apache::Constants qw(:common);
sub handler {
my $r = shift;
my $uri=$r->uri;
return DECLINED if ($r->filename !~ /foobar/);
print STDERR "in MyLog handler, \$uri=$uri, modify it now\n";
$r->uri('/foobar_changed');
return OK;
}
1;
When this is installed like this:
<Location /perl>
PerlLogHandler Apache::MyLog
</Location>
I can see the debugging message in error_log but the url logged
in the weblog is still the same as before.
Thanks for any info.
Richard
Re: modify url in web log via PerlLogHandler
Posted by Richard Chen <ch...@snet.net>.
I did not get any responses so I consulted the sources
of both apache and mod_perl. It turned out that apache uses
the_request method to get data for the log entries.
The eagle book documented this the_request as
a read-only method. Fortunately in the recent versions of mod_perl
this is not the case any more and one can set a new value
via this method.
So modifying url in web log via PerlLogHandler is indeed possible.
Just modify the_request value instead of the uri value.
HTH for other people.
Thanks
Richard
On Sat, May 26, 2001 at 09:23:17AM -0400, Richard Chen wrote:
> Is it possible to modify the logged url in the usual
> modperl weblog via PerlLogHandler? I have tried this and
> it does not seem to work:
>
> $ cat Apache/MyLog.pm
> package Apache::MyLog;
> use Apache::Constants qw(:common);
> sub handler {
> my $r = shift;
> my $uri=$r->uri;
> return DECLINED if ($r->filename !~ /foobar/);
> print STDERR "in MyLog handler, \$uri=$uri, modify it now\n";
> $r->uri('/foobar_changed');
> return OK;
> }
> 1;
>
> When this is installed like this:
>
> <Location /perl>
> PerlLogHandler Apache::MyLog
> </Location>
>
> I can see the debugging message in error_log but the url logged
> in the weblog is still the same as before.
>
> Thanks for any info.
>
> Richard