perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alden DoRosario <adorosa...@chitika.com>
Subject Re: Modifying the Apache Log Entry
Date Wed, 10 Jan 2007 19:40:45 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Tahoma">&gt; </font></font>the typical
way
to do this is to add something to $r-&gt;notes and use the %{Foobar}n
<font size="-1"><font face="Tahoma"><br>
Woohoo .. rock on .. this worked. <br>
<br>
For posterity, here is what worked: <br>
1) Add a note in the modperl code with the variable to be logged<br>
sub append_to_log {<br>
&nbsp; my ($r, $plog) = @_;<br>
&nbsp; $r-&gt;notes-&gt;set('SYSINFO' =&gt; "&amp;sysinfo=" .
uri_escape(join("&amp;", @{$plog})));<br>
}<br>
<br>
2) Modify the apache configuration so that you are logging the new
variable. I also has to replace "%r" with "%m %U%q" since I needed to
append to the URI) <br>
LogFormat "%h %l %u %t \"%m %U%q%{SYSINFO}n %H\" %&gt;s %b
\"%{Referer}i\" \"%{User-Agent}i\"" combined<br>
<br>
&gt; </font></font>opening up $r-&gt;request_line() is probably
acceptable. <br>
Regarding this issue (and the follow on responses to it), my vote would
go to making it writable again. Having old code work is huge for grunts
like me. The approach above seems to have solved the major problem
(logging the data) but is introducing side effects (for example, if I
have not set a note for <font size="-1"><font face="Tahoma">SYSINFO or
if apache is serving a static file like index.html, it is getting
logged as index.html-&nbsp; -- notice the dash at the end). </font></font><br>
<br>
Naive question: If making request_line writable again is accepted, when
should it make it to a stable release ? <br>
<br>
Thanks so much for your help guys. Really appreciate it. <br>
<br>
- Alden. <br>
<br>
<br>
<br>
Geoffrey Young wrote:
<blockquote cite="mid45A42961.8020701@modperlcookbook.org" type="cite">
  <blockquote type="cite">
    <pre wrap="">Can anyone suggest an alternate way of modifying the log entry ? 
    </pre>
  </blockquote>
  <pre wrap=""><!---->
the typical way to do this is to add something to $r-&gt;notes and use the %{Foobar}n

syntax as documented in

  <a class="moz-txt-link-freetext" href="http://httpd.apache.org/docs/2.0/mod/mod_log_config.html">http://httpd.apache.org/docs/2.0/mod/mod_log_config.html</a>

in fact, there is a whole flood of variables you can use for this - so
many that you can fake $r-&gt;the_request() in a LogFormat with it's
various components.  see, for example, recipe 16.3 here:

  <a class="moz-txt-link-freetext" href="http://www.modperlcookbook.org/chapters/ch16.pdf">http://www.modperlcookbook.org/chapters/ch16.pdf</a>

which shows both your method and an alternate way to achieve the same
thing.  you could certainly add what you want using these, I'd think.

  </pre>
  <blockquote type="cite">
    <pre wrap="">In
other words, what way does MP2 allow for us to control what gets logged
to the Apache access_log ?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
in general, mod_perl has nothing to do with this - you're using mod_perl
to be devious and change around what gets logged.  the proper approach
is probably to be straightforward about what you're logging.

  </pre>
  <blockquote type="cite">
    <pre wrap="">Alternatively: Can the_request in Apache::RequestRec be made writable
again so that it works like before ?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">From: <a class="moz-txt-link-freetext" href="http://search.cpan.org/dist/mod_perl/Changes">http://search.cpan.org/dist/mod_perl/Changes</a>
Apache::RequestRec methods changes [Stas] - readwrite =&gt; readonly:

   connection, canonical_filename, header_only, main, next, prev,
   pool, per_dir_config, request_config, proto_num, protocol,
   request_time, server, the_request, unparsed_uri
    </pre>
  </blockquote>
  <pre wrap=""><!---->
opening up $r-&gt;request_line() is probably acceptable.  I'd also consider
protocol and maybe proto_num (after researching what it is),
unparsed_uri, and perhaps header_only.  but that's about all.

thoughs from other devs?

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:dev-unsubscribe@perl.apache.org">dev-unsubscribe@perl.apache.org</a>
For additional commands, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:dev-help@perl.apache.org">dev-help@perl.apache.org</a>

  </pre>
</blockquote>
<br>
</body>
</html>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message