netserve
06-06-2001, 02:29 PM
I've just had play with the split-logfiles script from the apache support folder.
(My logs start with the %v so I can see which site was called)
It's outputting the data to files xaa, xab and xac, which isn't what I was expecting. Am I missing something with this?
No errors were produced but it's not split the log file by domain, but possibly date?
jtan15
06-06-2001, 04:43 PM
I'm not sure how to do this with that program, but it would be rather easy to whip up a perl program to do it for you.
What are you looking to do? Split the log files per user?
netserve
06-06-2001, 05:10 PM
Yep, just a case of splitting the log file into separate files based on the domain name in %v.
The script is only 8 or 9 lines long and is well commented but I'm not a perl expert and can't understand how it's supposed to be working.
jtan15
06-06-2001, 08:28 PM
An easy way to do that would be:
grep www.domainname.com /var/log/httpd/access_log >>/home/user/logs/access_log
Note, you can do just this in the Apache vhost. Simply add:
CustomLog /path/to/access_log
in the vhost of the user, and all of the access log entries will go to that file instead of the master file.
If one of those methods doesn't work for you, post the source of that perl program and we can see how to fix it. :)
cperciva
06-06-2001, 09:52 PM
Originally posted by Vincent Paglione
grep www.domainname.com /var/log/httpd/access_log >>/home/user/logs/access_log
A better solution would be
grep ^www.domainname.com /var/log/httpd/access_log >>/home/user/logs/access_log
since that only pulls out lines which *start* with "www.domainname.com" rather than any line which includes it (probably not an issue, but it might be).
If you have several vhosts which you're splitting logs for, you might want to "sort -k 1,1 -s" the logfile and then split the logfile by vhost (now that it is nicely sorted).
Or, you could use Apache's split-logfile script... just remember that there isn't a space between "split" and "-logfile" (it's a single word) or you'll end up calling the "split" command with option "-logfile" -- which "splits the given file into files of 1000 lines each with lexically ordered names taken from "xaa-zzz".
netserve
06-07-2001, 12:34 PM
That's what was happening when I ran the script. It was splitting the log file into 3 similar sized files whith the names above.
I'm sure that I didn't put a space between the -
Very strange. ?
netserve
06-07-2001, 04:07 PM
I've worked out what was going on, lol.
The first error from the script was caused by not having the correct path to perl! Doh!
As the error was file not found, I renamed the script to split not realising that there was a bash command with the same name.
It's all working now :-)
If I can just work out how to get procmail to split emails out to each user correctly I'm sorted. :-)