public class LogHelper
{
String infoPath;
String errorPath;
Int32 line = 0;
public LogHelper()
{
var dirPath = String.Format(@"Log路径");
if (!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath);
infoPath = dirPath + @"\文件名";
errorPath = dirPath + @"\文件名";
if (!File.Exists(infoPath))
File.Create(infoPath).Close();
if (!File.Exists(errorPath))
File.Create(errorPath).Close();
}
public void Info(string logStr)
{
line++;
StreamWriter writer = File.AppendText(infoPath);
writer.WriteLine("");
writer.WriteLine(logStr);
writer.Flush();
writer.Close();
}
public void Error(string
C# 简单实现LogHelper
最新推荐文章于 2024-04-07 19:28:16 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)