title: Multiple users writing at the same file
body: <p>I have a project which is a Web API project, my project is accessed by multiple users (i mean a really-really lot of users). When my project being accessed from frontend (web page using HTML 5), and user doing something like updating or retrieving data, the backend app (web API) will write a single log file (a .log file  but the content is JSON).
  The problem is, when being accessed by multiple users, the frontend became unresponsive (always loading). The problem is in writing process of the log file (single log file being accessed by a really-really lot of users). I heard that using a multi threading technique can solve the problem, but i don't know which method. So, maybe anyone can help me please.
  Here is my code (sorry if typo, i use my smartphone and mobile version of stack overflow):</p>
  
  <pre><code>public static void JsonInputLogging&lt;T&gt;(T m, string methodName)
  {
      MemoryStream ms = new MemoryStream();
      DataContractJsonSerializer ser = new 
              DataContractJsonSerializer(typeof(T));
      ser.WriteObject(ms, m);
      string jsonString = Encoding.UTF8.GetString(ms.ToArray());
      ms.Close();
      logging("MethodName: " + methodName + Environment.NewLine + jsonString.ToString());
  }
  
  
  public static void logging (string message)
  {
      string pathLogFile = "D:\jsoninput.log";
      FileInfo jsonInputFile = new FileInfo(pathLogFile);
      if (File.Exists(jsonInputFile.ToString()))
      {
          long fileLength = jsonInputFile.Length;
          if (fileLength &gt; 1000000)
          {
              File.Move(pathLogFile, pathLogFile.Replace(*some new path*);
          }
      }
      File.AppendAllText(pathLogFile, *some text*);
  }
  </code></pre>