Return-Path: Delivered-To: apmail-httpd-users-archive@www.apache.org Received: (qmail 78764 invoked from network); 4 Dec 2003 20:20:06 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Dec 2003 20:20:06 -0000 Received: (qmail 54334 invoked by uid 500); 4 Dec 2003 20:19:33 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 54307 invoked by uid 500); 4 Dec 2003 20:19:32 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 54240 invoked from network); 4 Dec 2003 20:19:32 -0000 Received: from unknown (HELO munk.nu) (213.152.51.194) by daedalus.apache.org with SMTP; 4 Dec 2003 20:19:32 -0000 Received: from munk by munk.nu with local (Exim 4.24; FreeBSD) id 1ARzwl-0004QD-Lr for users@httpd.apache.org; Thu, 04 Dec 2003 20:19:35 +0000 Date: Thu, 4 Dec 2003 20:19:35 +0000 From: Jez Hancock To: users@httpd.apache.org Message-ID: <20031204201935.GB16053@users.munk.nu> Mail-Followup-To: users@httpd.apache.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i Sender: User Munk X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Subject: Re: [users@httpd] Windows Apache logrotate X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Thu, Dec 04, 2003 at 11:07:05AM -0800, Ian Huynh wrote: > logrotate vs cronolog? > > http://www.cronolog.org/ > > I am curious as to which is the preferred method? cronolog is ok, but it does eat up a lot of file descriptors - 2(?) per logging pipe. I've never used logrotate - for my main request logging I use this: CustomLog "| /usr/local/sbin/logger.pl" commonvhost where logger.pl looks like this: -snip- #!/usr/bin/perl # Script to pipe apache log entries to virtually hosted log files # Assumes httpd.conf has the following: # LogFormat "%v %h %l %u %t \"%r\" %>s %b" commonvhost # and that ONLY the following logging line is used in the httpd.conf: # CustomLog "| /path/to/logger.pl" commonvhost # DO NOT configure the CustomLog directive in the vhost stubs for vhosts # or this will not work. # File logs commonvhost entries to a logfile with a template of: # /var/log/httpd/virtual.domain/$year/$month/$day use strict; =comment my $sample = 'www.savelua.com 68.35.248.247 - - [13/Jul/2003:00:01:28 -0500] "GET /images/link_images/br_to_uk.png HTTP/1.1" 200 10202 "http://forums.devshed.com/t66206/sfd0f2685db185532b3c8e1ae5b7bebfe.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)" '; $_=$sample; =cut my $logEntry = <>; # get the vhost from this log entry: $logEntry=~/(.*?) /; my $vhost = $1; # strip leading www.: $vhost=~s/^www\.//; my ($year, $month, $day) = ( (localtime)[5]+1900, sprintf("%02d", (localtime)[4]+1), sprintf("%02d", (localtime)[3]) ); # Name of access logfiles: my $accessLogName = "httpd-access.log"; =comment $logdir: Location to put all logfiles This will log everything into: $logdir/all/$year/$month/$day/httpd-access.log and put individual vhost logfiles into: $logdir/$vhost/$year/$month/$day/httpd-access.log =cut my $logDir = "/var/log/httpd"; my $allLogDir = "$logDir/all/$year/$month/$day"; my $vhostLogDir = "$logDir/$vhost/$year/$month/$day"; writeLog($allLogDir, "all"); writeLog($vhostLogDir, "vhost"); # write a log entry to a file sub writeLog(){ my $logDir = shift @_; my $type = shift @_; if( ! -d $logDir ) { `mkdir -p $logDir`; } open(FD, ">>$logDir/$accessLogName"); # if type is vhost, strip off the vhost data: if($type eq "vhost"){ $logEntry =~s/.*? //; } print FD $logEntry; close FD; } -snip- This script does me for now (around 50 vhosts), although I'm considering changing the script above so it uses a fifo(?) to handle higher volume hitrates better. If anyone has any suggestions please let me know - I'm not too sure how to do it. I did find a decent perl script somewhere someone had come up with that did an almost identical task to the above but using a more reliable method - can't for the life of me find the script now :( -- Jez Hancock - System Administrator / PHP Developer http://munk.nu/ --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org " from the digest: users-digest-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org