添加报错记录
This commit is contained in:
commit
2b50338365
1 file changed
+29
-3
+29
-3
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using Svg;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -42,6 +44,10 @@ namespace formula_manage
|
||||
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||
}
|
||||
|
||||
string Log_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
||||
//string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件
|
||||
|
||||
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
|
||||
@@ -59,10 +65,30 @@ namespace formula_manage
|
||||
MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" + Environment.NewLine
|
||||
// + "(2)错误源:" + e.Exception.InnerException.Source + Environment.NewLine
|
||||
+ "错误信息:" + e.Exception.Message + Environment.NewLine
|
||||
// + "(4)详细信息:" + e.Exception.InnerException.Message + Environment.NewLine
|
||||
// + "(5)报错区域:" + e.Exception.InnerException.StackTrace
|
||||
// + "(4)详细信息:" + e.Exception.InnerException.Message + Environment.NewLine
|
||||
// + "(5)报错区域:" + e.Exception.InnerException.StackTrace
|
||||
);
|
||||
}
|
||||
|
||||
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
||||
if (!File.Exists(logpath + Log_time + "Log.txt"))//检查日志文件并写入启动日志
|
||||
{
|
||||
FileStream fs = new FileStream(logpath + Log_time + "Log.txt", FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine("||["+ Log_time + "];[Error source] ||" + e.Exception.Source + Environment.NewLine);
|
||||
wr.WriteLine("||[" + Log_time + "];[Details] ||" + e.Exception.Source + Environment.NewLine);
|
||||
wr.WriteLine("||[" + Log_time + "];[Error area] ||" + e.Exception.Source + Environment.NewLine);
|
||||
wr.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
FileStream fs = new FileStream(logpath + Log_time + "Log.txt", FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine("||[" + Log_time + "];[Error source] ||" + e.Exception.Source + Environment.NewLine);
|
||||
wr.WriteLine("||[" + Log_time + "];[Details] ||" + e.Exception.Source + Environment.NewLine);
|
||||
wr.WriteLine("||[" + Log_time + "];[Error area] ||" + e.Exception.Source + Environment.NewLine);
|
||||
wr.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user