//写日志
public void WriteLog(string erroLog)
{
var pFileName = DateTime.Now.ToString("yyyy-MM-dd"); //文件名
string pSaveLogPath = Directory.GetCurrentDirectory();//获取绝对路径
string pSaveLogName = pSaveLogPath + "\\" + pFileName + "_ErrorLog.txt";//完整LOG文件路径
//判断当日日志文件是否存在
if (File.Exists(pSaveLogName))
{
//已存在,从文件结束处添加新的日志
FileStream fileStream = new FileStream(pSaveLogName, FileMode.Append, FileAccess.Write);
StreamWriter LogWriter = new StreamWriter(fileStream);
var longerrorStr = erroLog; //错误信息
LogWriter.WriteLine(longerrorStr);//文件写入
LogWriter.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&g
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交