From owner-freebsd-questions@FreeBSD.ORG Thu Jul 17 14:11:13 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B9FB106564A for ; Thu, 17 Jul 2008 14:11:13 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id A65B18FC22 for ; Thu, 17 Jul 2008 14:11:12 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.2/8.14.2) with ESMTP id m6HEB2c8098268; Thu, 17 Jul 2008 15:11:04 +0100 (BST) (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.6.0 smtp.infracaninophile.co.uk m6HEB2c8098268 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1216303864; bh=JOEsWFo05JObQJ bt5Je6ofbR7L8+zeqIw3KK0nAfrSg=; h=Message-ID:Date:From:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Cc:Content-Type: Date:From:In-Reply-To:Message-ID:Mime-Version:References:To; z=Mes sage-ID:=20<487F52EE.2050907@infracaninophile.co.uk>|Date:=20Thu,=2 017=20Jul=202008=2015:10:54=20+0100|From:=20Matthew=20Seaman=20|Organization:=20Infracaninophile|User -Agent:=20Thunderbird=202.0.0.14=20(X11/20080607)|MIME-Version:=201 .0|To:=20Mario=20Lobo=20|CC:=20freebsd-ques tions@freebsd.org|Subject:=20Re:=20log=20size=20handling|References :=20<487F2525.3030304@lcwords.com>=09<20080717072023.4b9e1d2f.wmora n@potentialtech.com>=09<487F2D9B.2010407@lcwords.com>=20<2008071709 04.26354.mario.lobo@ipad.com.br>|In-Reply-To:=20<200807170904.26354 .mario.lobo@ipad.com.br>|X-Enigmail-Version:=200.95.6|Content-Type: =20multipart/signed=3B=20micalg=3Dpgp-sha256=3B=0D=0A=20protocol=3D "application/pgp-signature"=3B=0D=0A=20boundary=3D"------------enig B2F5BCB51EBE7DB841C9038B"; b=Swet8diIxChQ2xjGkGdyNX4gs4VkSWhA8H5r1G XiMqDxD0VGX8qa4wYKi+ZHS/6qzVX/7Y0XtDQ6YHHz5YUv+WjMKnDickGPJNznkM62+ oeRko7rgVRrov7zMCcEKTW6gCsYfqohUAvQQrQpVo1Bfu4DfhpN3RWqB+LLp6C8B0g= Message-ID: <487F52EE.2050907@infracaninophile.co.uk> Date: Thu, 17 Jul 2008 15:10:54 +0100 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.14 (X11/20080607) MIME-Version: 1.0 To: Mario Lobo References: <487F2525.3030304@lcwords.com> <20080717072023.4b9e1d2f.wmoran@potentialtech.com> <487F2D9B.2010407@lcwords.com> <200807170904.26354.mario.lobo@ipad.com.br> In-Reply-To: <200807170904.26354.mario.lobo@ipad.com.br> X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigB2F5BCB51EBE7DB841C9038B" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (smtp.infracaninophile.co.uk [IPv6:::1]); Thu, 17 Jul 2008 15:11:04 +0100 (BST) X-Virus-Scanned: ClamAV 0.93.1/7736/Thu Jul 17 14:11:09 2008 on happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: freebsd-questions@freebsd.org Subject: Re: log size handling X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2008 14:11:13 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB2F5BCB51EBE7DB841C9038B Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Mario Lobo wrote: =20 > What would be the proper way to set the rotation of apache logs in=20 > newsyslog.conf when there are separate log files for each virtual host?= >=20 > Do I have to rotate them myself via a script in crontab? There are several ways to do this. Here's three in addition to the script that someone else just posted: * Use the 'G' option to newsyslog. 'G' says that the filename field of newsyslog.conf actually contains a shell globbing pattern (wildcard) and files matching that should be rotated and compressed. * Use the rotatelogs program that comes with Apache. In this case, you replace the logging configuration statements in https.conf eg. instead of: CustomLog "/var/log/httpd-access.log" combine you have: CustomLog "|/usr/local/sbin/rotatelogs /var/log/httpd-access.log= 86400" which will create a new log file every 86400 seconds (=3D 1 day) and label each one with the unix time it was created appended to the name. eg: /var/log/httpd-access.log.1216252800 That will change files at midnight UTC each day, which is fine if your server lives in the UK but not quite as convenient if your server is in Australia. * Use the conceptually very similar program 'cronolog' (in ports as sysutils/cronolog) This works like 'rotatelogs' except that you give it a date-time pattern using the %-escapes as in strftime(3) -- so =20 CustomLog "|/usr/local/sbin/cronolog /var/log/%Y/%m/%d/httpd-acce= ss.log" will create /var/log/2008/07/17/httpd-access.log for today's traffic. Timestamps are based on the TZ setting the server uses I believe, so would likely be the same as local wall-clock time. With the last two, there's no facility to compress or delete old log files: however it is pretty simple to write a very small shell script to do either of those things. The last two have the subtle advantage that you don't need to signal apache at file rotation time, which means there is absolutely no effect on performance when it switches to a new log file= =2E =20 You could switch log files every hour on a really busy site and not notice the overhead. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enigB2F5BCB51EBE7DB841C9038B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAkh/UvYACgkQ8Mjk52CukIza+ACaAmwZ1YANDoo+Mqd8VvQeaXKj SewAnRkgOd+72UUokS3RDCEaqRGxCxea =H2VS -----END PGP SIGNATURE----- --------------enigB2F5BCB51EBE7DB841C9038B--