Subject: | can't find custom log file |
Distribution name: Apache-ParseLog-1.02
Perl version: v5.6.1 built for i586-linux
OS: Linux ihp-lx2 2.4.10-64GB-SMP #1 SMP Fri Sep 28 17:26:36 GMT 2001 i686 unknown
Vendor: Suse
---------------------------
The following:
#!/usr/bin/perl
use Apache::ParseLog;
$base = new Apache::ParseLog("/etc/httpd/httpd.conf");
print "customlog defined: " . $base->customlogDefined('common') . "\n";
$customlog = $base->getCustomLog('common');
produces the following messages:
customlog defined: 1
Apache::ParseLog::getCustomLog: common does not exist, Exiting at ./checklog.pl line 7
Diagnosis:
doing a Data::Dumper on $base shows the following:
'customlog' => {
'format' => {
'common' => '%h %l %u %t \\"%r\\" %>s %b',
'agent' => '%{User-agent}i',
'combined' => '%h %l %u %t \\"%r\\" %>s ...',
'referer' => '%{Referer}i -> %U'
},
'location' => { '' => '/var/log/httpd/access_log'
},
'nickname' => [
'common'
]
},
i.e. the key in the 'location' hash is empty (I guess it should
be 'common' ?).
Possible Fix:
I replaced the code around line 446 in ParseLog.pm
} elsif ($line =~ /^CustomLog\s+(.+)\s+(\w+)$/) {
my($loc) = $1;
push(@nickname, $2);
if ($loc =~ m#\|#) { undef $loc }
elsif ($loc !~ m#^/#) { $loc = "$serverroot/$loc" }
$location{$2} = $loc;
}
by the following:
} elsif ($line =~ /^CustomLog\s+(.+)\s+(\w+)$/) {
my($loc) = $1;
my($nn) = $2;
push(@nickname, $2);
if ($loc =~ m#\|#) { undef $loc }
elsif ($loc !~ m#^/#) { $loc = "$serverroot/$loc" }
$location{$nn} = $loc;
}
It seems to work now.
best regards,
Andre