Apache Log Rotation & Statistics
Colin J. Raven
colin at kenmore.kozy-kabin.nl
Wed Jan 12 15:18:22 PST 2005
On Jan 12 at 18:03, Gadi Golan wondered aloud:
>
> I have Apache 2.x running with a collection of virtual hosts, each
> logging to their own access.log file. I want to offer log statistics
> to all of my virtual hosts on an individual basis. I want them to be
> able to go to say log.theirdomain.com or www.theirdomain.com/log and
> be able to view the statistics for their site from day x, week y,
> month z, year k, whatever. Ideally these logs will be stored
> compressed and in a directory specific to their virtual domain.
Well, just some thoughts straight out of the box:
Since you have individual logs for each virtual site, logrotate should
do much of what you're aiming for I believe.
If you don't already have it installed it's in;
/usr/ports/sysutils/logrotate
There's a ton of highly useful stuff in the logrotate man pages,
although I use few of the possibilities myself, and really when I think
about it, ought to use more. Here's something that is apropos of your
situation: (from man logrotate)
The file you're immediately concerned with in the beginning BTW is:
/etc/logrotate.conf
CONFIGURATION FILE
logrotate reads everything about the log files it should be
handling from the series of configuration files specified on the
command line.
Each configuration file can set global options (local definitions
over-ride global ones, and later definitions override earlier
ones) and specify a logfile to rotate. A simple configuration file
looks like this:
# sample logrotate configuration file
compress
/var/log/messages {
rotate 5
weekly
postrotate
/sbin/killall -HUP syslogd
endscript
}
"/var/log/httpd/access.log" /var/log/httpd/error.log {
rotate 5
mail www at my.org
size=100k
sharedscripts
postrotate
/sbin/killall -HUP httpd
endscript
}
/var/log/news/news.crit {
monthly
rotate 2
olddir /var/log/news/old
missingok
postrotate
kill -HUP `cat /var/run/inn.pid`
endscript
nocompress
As you can see, there is much which you can use here. Logrotate is a
powerful utility and may be perfect for your purposes.
Good luck & HTH,
-Colin
More information about the freebsd-questions
mailing list