Marcin Kasperski wrote:
> I am to provide some custom logging in my mod_perl
> application. Omitting some unnecessary details, I need to store some
> information after processing each request, putting this info into some
> central log (be it file or database) common for all apache processes
> and (if possible) common for multiple machines.
>
> I would like to ask for any suggestions/hints/patterns/... but there
> are also some specific qustions:
>
> 1) Apache somehow gathers notes from multiple processes into single
> access.log and error.log. Is it possible to reuse this functionality
> somehow for writing my custom information somewhere else? Considering
> such functionality is already present I would not like to reimplement
> logic protecting from simultaneous write from multiple processess...
you can write the information anywhere you want. not reinventing the
wheel is usually preferred, though :)
the access_log is much easier to handle than the error_log, fwiw.
>
> 2) Looking at the name, seems it is LogHandler where custom logging
> should take place. But does it really give real advantage over just
> logging on the end of PerlHandler?
you can pretty much shove just about everything into the PerlHandler
if you wanted to - that's what most other application environments end
up doing anyway (CGI, ASP, servlets...). the cool thing about
mod_perl is that you get access to the various apache phases, and
utilizing them for what they were designed for makes your application
cleaner.
> If so, how should I pass data
> between handlers - just stick to some perl global variable or use
> pnotes?
pnotes is one way to do it. the approach victor described in his
email is another. the cookbook chapter on logging has some ideas that
might suit you (including victor's in 16.4)
http://www.modperlcookbook.org/chapters/ch16.pdf
>
> 3) Are there any tools of 'gather logs from multiple machines to the
> central location' you would recommend?
mod_log_spread appears to be very popular, though I haven't used it
myself.
HTH
--Geoff