From owner-freebsd-questions@FreeBSD.ORG Wed Jan 12 23:18:22 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8074F16A4CE for ; Wed, 12 Jan 2005 23:18:22 +0000 (GMT) Received: from t-x.dignus.nl (t-x.dignus.nl [83.219.88.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D44143D39 for ; Wed, 12 Jan 2005 23:18:22 +0000 (GMT) (envelope-from colin@kenmore.kozy-kabin.nl) Received: from localhost (localhost.dignus.nl [127.0.0.1]) by t-x.dignus.nl (Safehouse) with ESMTP id C9C3528626; Thu, 13 Jan 2005 00:18:34 +0100 (CET) Received: from kenmore.kozy-kabin.nl (cjr-home [62.251.72.148]) by t-x.dignus.nl (Safehouse) with ESMTP id 47D852861A; Thu, 13 Jan 2005 00:18:27 +0100 (CET) Received: from kenmore.kozy-kabin.nl (localhost.kozy-kabin.nl [127.0.0.1]) by kenmore.kozy-kabin.nl (Postfix) with ESMTP id AD10B6230; Thu, 13 Jan 2005 00:18:10 +0100 (CET) Received: from localhost (colin@localhost)j0CNI5g5034078; Thu, 13 Jan 2005 00:18:10 +0100 (CET) (envelope-from colin@kenmore.kozy-kabin.nl) Date: Thu, 13 Jan 2005 00:18:05 +0100 From: "Colin J. Raven" To: Gadi Golan In-Reply-To: <1534551b05011215032348e616@mail.gmail.com> Message-ID: <20050113000524.E802@kenmore.kozy-kabin.nl> References: <1534551b05011215032348e616@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by RemSPAMd at ph230.plushosting.nl cc: freebsd-questions@freebsd.org Subject: Re: Apache Log Rotation & Statistics X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2005 23:18:22 -0000 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@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