看到脚本之家的一片关于:C#使用读写锁三行代码简单解决多线程并发的问题
决定试一试,便修改了一下之前的代码,以适应多线程需求。

使用单例队列实现多线程日志请参考:
https://www.cnblogs.com/lijuanfei/p/8616877.html
C#使用读写锁三行代码简单解决多线程并发的问题,原文请参考:
https://blog.csdn.net/zdhlwt2008/article/details/80702605
代码如下:

public class LogHelper
{
    //读写锁,当资源处于写入模式时,其他线程写入需要等待本次写入结束之后才能继续写入
    private static ReaderWriterLockSlim LogWriteLock = new ReaderWriterLockSlim();
    /// <summary>
    /// 写日志
    /// </summary>
    /// <param name="text">消息文本text</param>
    public static Boolean WriteLog(string text)
    {
        Boolean ret = false;
        try
        {
            LogWriteLock.EnterWriteLock();
            string path = AppDomain.CurrentDomain.BaseDirectory;
            path = System.IO.Path.Combine(path, "Logs\\");
            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }
            string fileFullName = System.IO.Path.Combine(path
            , string.Format("{0}.txt", DateTime.Now.ToString("yyyyMMdd")));
            using (StreamWriter output = System.IO.File.AppendText(fileFullName))
            {
                output.Write(text);
                output.Close();
            }
            ret = true;
        }
        catch (Exception e) { ret = false; }
        finally
        {
            LogWriteLock.ExitWriteLock();
        }
        return ret;
    }
}

调用方式:

HelperLibs.LogHelper.WriteLog("This IS A Log Record!!\r\n");

以上,希望能有帮助,谢谢