in reply to Working with Access Logs

as logs are almost sorted by date, you could probably limit your search on the error log to a small window:
my $window = 300; # 5 min. my @errors; my @timestamps; while (<ACCESSLOG>) { my $timestamp = get_timestamp($_); while (!@timestamps or $timestamps[-1] < $timestamp + $window) { if (defined(my $err = <ERRORLOG>)) { push @errors, $err; push @timestamps, get_timestamp($err); } else { last; } } while (@timestamps and $timestamps[0] < $timestamp - $window) { shift @errors; shift @timestamps; } for my $error (@errors) { # check if access line $_ matchs # with error line $error here: ... } }

Replies are listed 'Best First'.
Re^2: Working with Access Logs
by superfrink (Curate) on Feb 28, 2006 at 12:15 UTC
    In the past I have used a C program called mergelog to merge and sort Apache CLF (Commong Log Format) log files. I used this when I had multiple web servers serving a set of websites.