Re: Rotating Log-Container
| From: | Ian Eure | Date: | Wed, 02 Feb 2005 21:53:29 +0000 |
| Subject: | Re: Rotating Log-Container | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-35891@lists.php.net to get a copy of this message | ||
On Wednesday 02 February 2005 01:19 pm, Stephan Wentz wrote:
> Ian Eure wrote:
> | But seriously, this is not a safe thing to be doing. It's terribly
> race-prone,
> | since you have no idea how many readers/writers the file has at any given
> | moment, and you stand a very good chance of corrupting things.
>
> Yea you're right with this one, but an external tool would have the same
> problems. Logfiles on our server grew large in a speed you can't
> imagine, and I don't wanna switch logs off, so I have to do *something*
>
Well, logrotate actually handles this pretty well, at least for persistent
daemons. (Summary: logrotate moves the current file - UNIX file i/o doesn't
care, since it opens by inode number - logrotate creates a new file and
signals the daemon, which closes the old logfile and opens the new)
I'm not sure how well it would actually work for PHP logs, since there's a lot
of open/write/close cycles going on. Is there actually a way to keep a file
handle open across PHP invocations? I suspect not, I think that PHP cleans up
all that stuff when the script terminates, otherwise this would be a perfect
solution.
Maybe you should look into logging with MySQL or one of the other log
containers.
> Thanks for your (negative? hehe) insights ;-)
>
Any time. :^)
Attachment: [application/pgp-signature]
Attachment: [application/pgp-signature]