Apache Log Helper

This is a shell script I wrote to help me with my web server logs.

Usage: alh [OPTION]... [PATTERN(S)]
Apache Log Helper.  View/search Apache log files.
The log file is grepped for PATTERN(s) if specified.
By default log files are looked for in /var/log/apache/.

-a          Use the alternate log file error.log.
-A          Use the alternate log file referer.log.
-c          Print only the number of lines matched.
-d          Print the command(s) that would execute. (Debug)
-e          Exclude local IP addresses.
-E          Use egrep in place of grep.
-f <file>   Obtain patterns from <file>. 
-F          Use fgrep in place of grep.
-h          Print this help text and exit.
-i          Ignore case on all matches.
-l <file>   Use <file> in place of access.log.
-n <lines>  Output <lines> lines when using -t.
-o          Use previous version of log file. Eg. access.log.0
-p          Send output to $PAGER or more.
-t          Send the output to tail.
-x <filter> Filter the output with the inverted pattern <filter>.
-X <file>   Same as -x but obtain patterns from <file>.

To install ALH simply follow these steps:

  1. Uncompress ALH using either unzip alh.zip or gunzip alh.gz.
  2. Modify the variables at the top of the file to suite your environment.
  3. Make the file executable using chmod +x alh.
  4. Copy it to a directory in your path, /usr/local/bin is a good location.

It is available as PKZip and Gzip. Last updated 2005-12-16.


  • 2005-10-28:
    Added the -A option for the referer log.
  • 2005-12-16:
    Added the -n option for the number of lines to output when using -t.

Note: I have only tested alh on my Linux servers at work and minimally on my Mac OS 10.2.8 PowerBook. I have not encountered any problems. Since I use the getopt program to parse the command line arguments ALH will not work everywhere. getopt is not always available and there are different implementations when it is.


Created with VIM. Valid HTML 4.01 Transitional.