Re: Rotating Log-Container
| From: | Olivier Guilyardi | Date: | Fri, 04 Feb 2005 12:51:49 +0000 |
| Subject: | Re: Rotating Log-Container | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-35937@lists.php.net to get a copy of this message | ||
Ian Eure wrote:
On Wednesday 02 February 2005 01:19 pm, Stephan Wentz wrote:What about flock() ?Ian Eure wrote: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.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*
Maybe you should look into logging with MySQL or one of the other log containers.Indeed, MySQL handles just fine all concurrent access issues. And it is available on most of the cheapest hosting solutions. From a mysql table, one can easily generate a log file on demand. But, still, I feel like you all people give up too easily on handling file-based concurrent access from PHP. This should be better investigated, with possibly new package(s) to help keeping files from getting corrupted. -- og