I've Apache 2 installed and running away, logging stuff towards the /logs folder known as "access/error.txt" And I'm wondering, when i perform a lot, Steps to make Apache produce a new ACCESS log apply for every unique IP that connects, and log all that user's demands within their particular file. For instance, a man at visits my server, apache instantly makes /logs/ and logs all accesses into it. Have it?

Thanks, I'm not sure if this sounds like possible. Hopefully someone knows. grumbles to self inaudibly

Allow me to first condition this generally is a bad idea, as you will have one file per Ip. It may seem that's awesome and simple to handle and all sorts of, til you have two million+ unique site visitors at the site and also you begin to encounter major issues. These problems include: really low disk performance, the inability to easily ls and rm within the logging directory, and the potential of drained of inodes prior to runing out of disk space. You've been cautioned.

Nevertheless, should you really still do, apache has got the CustomLog directive:


With this particular you could do this something similar to this:

CustomLog "|/path/to/script" common 

Where /path/to/script is really a program that reads stdin, and creates out files in line with the Ip given. You'd need to write this yourself, as I am unaware of anything available that performs this. It could look something similar to this (perl):


while (<STDIN>) {

    if ($_ =~ /^(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)/) {
        open FILE, ">>", "/path/to/log/dir/" . $1 . ".txt";
        print FILE $_;
        close FILE;
    } else {
        print STDERR "invalid input format!\n";


This script is simply a good example, as it'll have race conditions and gratifaction problems, because it opens and shuts the file upon each entry. Careful, though, just like you must many open filehandles at the same time, you will be not able to spread out anymore.