How to append a string to the content of a error log file in an highly frequented environment?
<p>From my age old php days (years ago) I slightly remember that I had <em>big</em> trouble with creating a log file in PHP. At random times, the file suddenly was plain blank (empty). I used something pretty close to this:</p>

<pre><code>$myFile = "myFile.txt";
$fh = fopen($myFile, 'a');
$str = "New Entry...\n";
fwrite($fh, $str);
fclose($fh);
</code></pre>

<p>Is that really a safe way to work with a error log file when there are like 500 users at the same time executing PHP scripts (by surfing the website)? Lets assume there's a really bad bug that causes every page view to produce an error log. That poor myFile.txt is then accessed like 100 times per second. I feel that this won't work. I hope I'm wrong.</p>

<p>How would you do that?</p>
