londonjim has asked for the wisdom of the Perl Monks concerning the following question:

I am struggling with Apache::ParseLog, I'm trying one of the examples from the documentation in which the script has to parse httpd.conf, read the LogFormat and CustomLog settings to pick up the location and format of the log file.

I'm using exactly this example:
http://search.cpan.org/~akira/Apache-ParseLog-1.02/ParseLog.pm#Example_2:_Referer_Report

All I get is the error message
"Apache::ParseLog::getCustomLog: combined does not exist, Exiting at ./refer.pl line 10"

Some time ago someone else had this very problem (http://www.perlmonks.org/?node_id=315092) but apparently never found the solution.

Can anyone provide any insight? Does that particular example script work for anyone else? Thanks in advance, Jim

Replies are listed 'Best First'.
Re: Problems with Apache::ParseLog
by rpanman (Scribe) on Aug 06, 2007 at 15:27 UTC
    Have you tried looking at the names of the customer logs using:
    @customlog = $base->customlog();
    This returns an array containing "nicknames" of the custom logs defined in the $httpd_conf. It is a nickname that you pass to the getCustomLog method.

    This is included in the cpan documentation Apache::ParseLog
      Yes, I've tried that - the array returned by $base->customlog() has only one value, 'combined' (this is presumably OK since there's only one LogFormat entry in my httpd.conf):

      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

      There is one CustomLog entry in my httpd.conf specifying the use of the 'combined' LogFormat:

      CustomLog /var/log/apache2/access_log combined

      Yet the script gives me the error:

      Apache::ParseLog::getCustomLog: combined does not exist, Exiting


      Thanks,
      Jim
Re: Problems with Apache::ParseLog
by rpanman (Scribe) on Aug 07, 2007 at 12:47 UTC
    I've had a play around with this in the debugger and found that you get this error if the ServerRoot in your Apache conf file has quotes around it. So if you change:
    ServerRoot "/usr/local/apache"
    to:
    ServerRoot /usr/local/apache
    Then it will probably work (certainly did for me). It looks like the module doesn't take the quotes into consideration...

    Update: I have raise a bug report on cpan Ticket 28717