Writing to a log file Thread safe using TextWriter.Synchronized
<p>Reading the documentation I thought this code would write logs to a file in a threadsafe way. </p>

<pre><code>using (TextWriter syncTextWriter = TextWriter.Synchronized(new StreamWriter(Server.MapPath(String.Format("~/App_Data/PaypalIPN/IPNlog_{0:yyyyMM}.txt", DateTime.Now)), true)))
{
  syncTextWriter.WriteLine(line);
  syncTextWriter.Close();
}
</code></pre>

<p>I do not have a high traffic site, but every now and again two people make a paypal payment at the same time, and this is the IPN payment log.  Despite introducing <code>TextWriter.Synchronized</code> I am still getting the odd exception:</p>

<pre><code>System.IO.IOException: The process cannot access the file ... 
...because it is being used by another process.
</code></pre>

<p>Where have I gone wrong?</p>
