c#简单日志类
2021-03-10 04:27
标签:help style dir try ade nal current ignore exit c#简单日志类 标签:help style dir try ade nal current ignore exit 原文地址:https://www.cnblogs.com/chlm/p/12720069.html public class LogHelper
{
private static readonly ReaderWriterLockSlim LogWriteLock = new ReaderWriterLockSlim();
private static readonly string LogFilePath = Environment.CurrentDirectory + "\\log.txt";
public static void Log(string content)
{
try
{
LogWriteLock.EnterWriteLock();
string data = DateTime.Now + ":" + content+Environment.NewLine;
File.AppendAllText(LogFilePath, data);
}
catch (Exception)
{
// ignored
}
finally
{
LogWriteLock.ExitWriteLock();
}
}
}