logging - Apache logs, name them by IP? -



logging - Apache logs, name them by IP? -

i have apache 2 installed , running away, logging stuff /logs folder called "access/error.txt" , wondering, lot, how create apache generate new access log file every unique ip connects, , log of user's requests in respective file. example, guy @ 173.49.91.61 visits server, apache automatically makes /logs/173.49.94.61.txt , logs accesses it. it?

thanks, don't know if possible. know. grumbles self inaudibly

let me first state bad idea, you'll have 1 file per ip address. may think that's cool , easy manage , all, until have 2 million+ unique visitors @ site , start run major issues. these issues include: low disk performance, not beingness able ls , rm in logging directory, , possibility of running out of inodes before run out of disk space. have been warned.

that said, if really still want this, apache has customlog directive:

http://httpd.apache.org/docs/current/logs.html#piped

with this:

customlog "|/path/to/script" mutual

where /path/to/script programme reads stdin, , writes out files based on ip address given. you'd have write yourself, i'm not aware of available this. might (perl):

#!/usr/bin/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 example, have race conditions , performance problems, opens , closes file upon each entry. careful, though, if have many open filehandles @ once, you'll unable open more.

apache logging ip

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -