Date: Thu, 17 Jul 2008 15:10:54 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Mario Lobo <mario.lobo@ipad.com.br> Cc: freebsd-questions@freebsd.org Subject: Re: log size handling Message-ID: <487F52EE.2050907@infracaninophile.co.uk> In-Reply-To: <200807170904.26354.mario.lobo@ipad.com.br> References: <487F2525.3030304@lcwords.com> <20080717072023.4b9e1d2f.wmoran@potentialtech.com> <487F2D9B.2010407@lcwords.com> <200807170904.26354.mario.lobo@ipad.com.br>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?487F52EE.2050907>