c# 添加日志
2021-05-20 02:29
标签:using sage ted private sys 创建 line mes color c# 添加日志 标签:using sage ted private sys 创建 line mes color 原文地址:https://www.cnblogs.com/Mzg121584668/p/11322940.htmlprivate static void setlog(string message)
{
string logPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\log\\";
if (!Directory.Exists(logPath))//没有则创建
{
Directory.CreateDirectory(logPath);
}
using (FileStream stream = new FileStream(logPath + DateTime.Now.ToString("yyyyMMddHHmm") + ".txt", FileMode.Append))
using (StreamWriter writer = new StreamWriter(stream))
{
writer.WriteLine($"{DateTime.Now}:{message}");
}
}