Re: Rotating Log-Container
| From: | Stephan Wentz | Date: | Thu, 03 Feb 2005 14:24:18 +0000 |
| Subject: | Re: Rotating Log-Container | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-35919@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
bertrand Gugger wrote:
| Hi Stephan, Ian & al.
|
|> | 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.
|
|
| Actually as you rotate (delete or rename) the current log file, you have
| a chance some other process has this file allready opened and wants to
| continue to write some log.
| If you rename the file, this other process will finish to write in this
| renamed file.
| If you delete the file, this other process has a *good chance* to loose
| its next lines in log,
| what is certainly bad.
| (tested with CLI concurrent scripts under linux)
| So, at least, you should never delete the current log file ($maxfiles >=
| 2 is a rule).
Ok, makes sense, so i will remove the option with $maxFiles==0
($maxFiles==1 will move log to log.1, so it should be >=1)
Hmm I'm thinking about what to do with $maxFiles==0. Unlimited amount of
logfiles? Would this make sense?
| The question of evaluating the size of the log should just use filesize.
| No need to complicate trying to get it in real time.
| As said you have perhaps concurrent scripts so they also push the size
| in mean time.
| If I assume, no very long processes will write big amounts of log in on
| run, a simple filesize before open is enough and doesn't cost.
| Anyway, why are you fixing on number of lines ? Just size is critical ?
Hmm good question ;-)
I've given up on the number of lines, thought it was a good idea (I
know, it wasn't, hehe).
| Hope that make sense.
It does, thanks for your input!
Stephan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCAjQS8qQ9XV7tBNQRAhOHAKCmCIWlRQjTd6sjnv6LFvi5aa2D2QCffLkg
TtV9+Q1pgrXOQZ+/6FxbsGY=
=uJbo
-----END PGP SIGNATURE-----