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

Dear monks,

Before I go off and re-invent the wheel, I thought I'd ask for your recommendations on CPAN modules to parse Apache logs. I just spent an hour fighting with Apache::ParseLog and I'm ready to give up on it. (The Apache::ParseLog methods I'm trying to use are all supposed to generate hashes whose keys are items of interest, such as user agent names, and whose values are hit counts; instead the keys of the hashes that I'm getting look very much like entire log file lines, and they all have value 1, suggesting that there are some bad regexes somewhere.)

Many thanks,

the lowliest monk

20050328 Edit by castaway: Changed title from 'ISO module to parse Apache logs'

  • Comment on Looking for a module to parse Apache logs

Replies are listed 'Best First'.
Re: Looking for a module to parse Apache logs
by jhourcle (Prior) on Mar 24, 2005 at 01:08 UTC

    I know it doesn't directly answer your question, but for most log analyzing needs, Analog does some great work. (it doesn't help you if you're trying to do more specific reporting than what they support, but it does a great job for those times when management wants 'metrics' and isn't specific in just what they want.)

    Oh -- and the apache logs are in what's known as 'common log format'. Searching for that, I found Regexp::Log::Common and AnyData::Format::Weblog, neither of which I've used.

    Update: Also not a CPAN module, but you might want to see the sample chapter from Perl for Web Site Management

Re: Looking for a module to parse Apache logs
by duct_tape (Hermit) on Mar 24, 2005 at 00:08 UTC

    Perhaps Apache::LogRegex will work for you. I haven't tried it though, so I can not say if it will work. It looks simple enough to use, and you can specify your log format.