Apache::Log::Spread - Perl implementation of mod_log_spread for multicasting access logs.
# In httpd.conf PerlModule Apache::Log::Spread PerlLogHandler 'Apache::Log::Spread->handler' SpreadDaemon 4903 MLS_LogFormat "%h %{$cookie->isVisitor?'V':'U'}perl %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" custom MLS_Log www custom
Apache::Log::Spread provides logging handlers to allow for Apache access logs to be multocast to a spread group. The configuration interface is a super-set of the Apache mod_log_config interface and allows for expansion of perl code.
The location of the spread daemon to connect to.
formatstring is a standard mod_log_config format line, the standard format options are all accepted (see the mod_log_config documentation for details), as well as the special tag %{...code...}perl, which evals the contained code and substitutes the results for the format specifier.
groupname is the name of the spread group to which logs should be multicast. formatname is the name of the MLS_LogFormat to use. should_print is an optional environment string to toggle transmission of logs. This can be used the way that mod_setenvif environment variables are used, or with a complete code block. For example, to only multicast requests for '.html' files we can use:
MLS_Log www custom "return ($r->uri =~ /\.html/) || ($r->uri =~ /$\//));"
Apache::Log::Spread is deigned to be extended to provide custom format string expansions. To extend it in ithis fashion, simply override the _interpolate_log_string function.
An example is
package My::SpreadLogger; use strict;
use Apache::Logger::Spread; use My::Cookies;
use vars qw( @ISA); @ISA = qw(Logger::Spread);
sub handler($$) { my $self = shift; my $ar = shift; Apache::Log::Spread::handler($self, $ar); }
sub _interpolate_log_string { my ($self, $logref) = @_; my $cookie = My::Cookie->new(); $$logref =~ s/%\{([\w-]+)\}cookie/$cookie->{$1} || '-'/ego; }
George Schlossnagle <george@omniti.com>
To install Logger::Spread, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Logger::Spread
CPAN shell
perl -MCPAN -e shell install Logger::Spread
For more information on module installation, please visit the detailed CPAN module installation guide.