【二开插件】- 个人日志工具类原创
金蝶云社区-baldboy
baldboy
16人赞赏了该文章 150次浏览 未经作者许可,禁止转载编辑于2024年07月15日 13:52:20
//sta--成功/失败标识:成功-true|失败-false
//str--日志信息
public static void WriteLogByFile(bool sta,string str)
{
	string text = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "MyLogs";
	bool flag = !Directory.Exists(text);
	if (flag)
	{
		Directory.CreateDirectory(text);
	}
	string path = text + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + "-Log.txt";

	StreamWriter streamReader = new StreamWriter(path, true);
	if (sta) 
	{
		streamReader.WriteLine(DateTime.Now + "--Info==>" + str);
	}
	else 
	{
		streamReader.WriteLine(DateTime.Now + "--Error==>" + str);
	}

	streamReader.Close();
	streamReader.Dispose();
}

image.png

image.png

赞 16