You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Randy J. Ray" <rj...@redhat.com> on 2002/02/12 03:31:25 UTC

About PerlLogHandler phase

Having gone over the Eagle book and the sample chapter of the cookbook (great
luck that, having one of the sample chapters coincidentally be the one that
covers the logging phase, since I haven't gotten my copy yet), I am still
unclear on a few things regarding the logging phase:

* If I install a handler for PerlLogHandler, does the normal logging still
  take place? Is it a function of whether my handler returns OK, DECLINED,
  etc.?

* Are there ways to register other log types, in addition to the access,
  error, etc.? Such that people could specify those (and a format) the
  same way they specify the others? More to the point, so that there
  might be a ready file-descriptor I could print to, rather than having to
  deal with the open/lock/write/unlock/close cycle.

To explain, I am looking at ways to expand the logging capability in my
Apache::RPC::Server class. I'd like at the very least to be able to alter the
URI part such that it reflects the procedure name that was called (this I
understand how to do). Ideally, I'd like to either write completely different
lines out to the access log, or (preferable) write to a separate log entirely,
so that tracking usage statistics is made that much easier. If I go the
separate log route, I don't want the server to be weighted down by the
repetitive open/close cycle on the files.

Randy
--
-------------------------------------------------------------------------------
Randy J. Ray     | Men occasionally stumble over the truth, but most of them
rjray@redhat.com | pick themselves up and hurry off as if nothing had happened.
+1 408 543-9482  |   -- Sir Winston Churchill

Re: About PerlLogHandler phase

Posted by David Wright <da...@busy-bee.net>.
On Mon, 11 Feb 2002, Paul Lindner wrote:

> On Mon, Feb 11, 2002 at 06:31:25PM -0800, Randy J. Ray wrote:
> >
> > * If I install a handler for PerlLogHandler, does the normal logging still
> >   take place? Is it a function of whether my handler returns OK, DECLINED,
> >   etc.?
>
> As far as I know return codes are ignored.  This means that all
> logging (and cleanup) handlers are called for each request.

Unless, I'm pretty sure, the PerlLogHandler returns SERVER_ERROR, in which
case log handling will stop. The client won't see the 'error' because it's
already received all the content.

dave



Re: About PerlLogHandler phase

Posted by Paul Lindner <li...@inuus.com>.
On Mon, Feb 11, 2002 at 06:31:25PM -0800, Randy J. Ray wrote:
>
> * If I install a handler for PerlLogHandler, does the normal logging still
>   take place? Is it a function of whether my handler returns OK, DECLINED,
>   etc.?

As far as I know return codes are ignored.  This means that all
logging (and cleanup) handlers are called for each request.

> * Are there ways to register other log types, in addition to the access,
>   error, etc.? Such that people could specify those (and a format) the
>   same way they specify the others? More to the point, so that there
>   might be a ready file-descriptor I could print to, rather than having to
>   deal with the open/lock/write/unlock/close cycle.

Apache::LogFile (section 16.2) is what you are looking for.  It gives
you a global filehandle that you can print to as much as you care to.

> To explain, I am looking at ways to expand the logging capability in my
> Apache::RPC::Server class. I'd like at the very least to be able to alter the
> URI part such that it reflects the procedure name that was called (this I
> understand how to do). Ideally, I'd like to either write completely different
> lines out to the access log, or (preferable) write to a separate log entirely,
> so that tracking usage statistics is made that much easier. If I go the
> separate log route, I don't want the server to be weighted down by the
> repetitive open/close cycle on the files.

You might also want to consider setting a notes value for each piece
of information you want to log.  This is detailed in section 16.4 of
the cookbook.  It's dead simple, just add this to your httpd.conf:

LogFormat "%{RPC_NAME}n %{RPC_ARGS}n %{RPC_RESULTS}n" rpc_log_format

<Location /RPCSERV>
 CustomLog logs/rpc_log rpc_log_format
</Location>

and then somewhere in your code do this:

 $r->notes('RPC_NAME', $cow);
 $r->notes('RPC_ARGS', $moo);
 $r->notes('RPC_RESULTS', $milk);


-- 
Paul Lindner    lindner@inuus.com   ||||| | | | |  |  |  |   |   |

    mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
         Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm