Sources under BSD licence

Return to Sources under BSD licence home page

split-logfile is a c-language program intended to be a more efficient drop-in replacement for the split-logfile perl script usually distributed with Apache's httpd webserver.

This program processes webserver access logfiles which have the virtual host name as the first field of the record. After the virtual host name there must be a space, e.g., the rest of the record...

The virtual host name and the space are removed, then the rest of the record is written to a file named in the current directory. This effectively splits the one main access logfile into a separate log file for each virtual host.

The input to split-logfile is from stdin, output files are placed in the current directory.

split-logfile < /var/log/webserver-access.log

To print stats (the number of log records per virtual host) to stdout at the end of the run, use the verbose flag, e.g.:

split-logfile -v < /var/log/webserver-access.log

Tested on OpenBSD 5.5beta, FreeBSD 8.3, FreeBSD 10.0, CentOS 6.3 (see note below)

BSD license

Download split-logfile 1.6 (3KB)


Note for CentOS 6.3 (and probably other recent versions of GNU-Linux) - change the line in the insert_hostname function that contains strlcpy to

strcpy(hfd->hostname, hn);