Date: Fri, 9 Jul 2004 12:02:12 -0400 From: Brian Clapper <brian-freebsd-003@clapper.org> To: freebsd-questions@freebsd.org Cc: graham.north@telus.net Subject: Re: Apache log rotation problems Message-ID: <200407091602.i69G2CqH025657@z.inside.clapper.org> In-Reply-To: <20040708224637.2c909d1b.wmoran@potentialtech.com> References: <002201c45111$801acb30$627ba8c0@phoenix> <20040613090822.GB75168@happy-idiot-talk.infracaninophile.co.uk> <003901c45197$9feda640$627ba8c0@phoenix> <20040616103837.GC3094@happy-idiot-talk.infracaninophile.co.uk> <002401c4655c$ecd47640$627ba8c0@phoenix> <20040708224637.2c909d1b.wmoran@potentialtech.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 8 July, 2004, at 22:46 (-0400) Bill Moran <wmoran@potentialtech.com> wrote: > "Graham North" <graham.north@telus.net> wrote: > > > Hello all: > > > > There has to be a simple fix to this problem - I am using newsyslog and cron > > to rotate my Apache logfiles. They get rotated and Apache keeps working > > however after a log rotation takes place Apache will not longer log my > > accesses. It does continue to serve pages but I need to do an apachectl > > restart in order for it to continue logging properly. > > > > newsyslog.conf and crontab files are attached for reference. > > You need to restart apache to get it to start logging to a new file. Luckily, > newsyslog can do this for you. > > With the default Apache install, Apache will log its PID to a file when it > starts, just add this filename (/var/run/httpd.pid) to the end of each > newsyslog entry that rotates an apache file, and newsyslog will automatically > send a HUP signal to that PID when the log file is rotated > > See the man pages for newsyslog for more detailed info. Another option is to use the sysutils/cronolog port. Configure it in httpd.conf, with ErrorLog and CustomLog directives similar to the following: ---- ErrorLog "|/usr/local/sbin/cronolog --symlink=/var/log/httpd/error_log /var/log/httpd/error_log_%y%m%d" CustomLog "|/usr/local/sbin/cronolog --symlink=/var/log/httpd/access_log /var/log/httpd/access_log_%y%m%d" combined ---- cronolog will rotate logs automatically each day. From the cronlog man page: Before writing a message cronolog checks the time to see whether the current log file is still valid and if not it closes the current file, expands the template using the current date and time to generate a new file name, opens the new file (creating missing directories on the path of the new log file as needed unless the program is compiled with -DDONT_CREATE_SUBDIRS) and calculates the time at which the new file will become invalid. See the man page for further details. I've been using it for awhile on my public web server. Seems to work just fine. -Brian Brian Clapper, http://www.clapper.org/bmc/ Scott's first Law: No matter what goes wrong, it will probably look right.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407091602.i69G2CqH025657>