How to separate Apache logs into flat files for each incoming ip address with Perl

logs.jpg

If you keep your Apache logs for a really long time, it is sometimes slow and inefficient to search through a bunch of log files to see what a certain host accessed on your web server. To get around this, I wrote a small Perl script that parses the access log and saves all the entries from each ip address into a separate file. A secondary option creates directories for the first octet of the ip address and then store the files with the given first octet in that directory. This way, the overhead is reduced if you have lots of searches through logs based on ip address.

proc_logpl.txt )

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>