C# 简单粗暴写日志

public static void WriteLog(string text)
{

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-HHmm")));


using (StreamWriter output = System.IO.File.AppendText(fileFullName))
{
output.WriteLine(text);

output.Close();
}
}

猜你喜欢

转载自www.cnblogs.com/cxxs1659666966/p/10782631.html