1 在.cs中執(zhí)行存儲(chǔ)過(guò)程
2
3 try
4
5 {}
6
7 catch(exception ex)
8 {
9 cm.connection.close() ;
10 qiao.value ="fail";
11 publicunit.saveerror(ex,this.context,this.request) ;
12 }
13
14
15
16 寫(xiě)日志的編寫(xiě)
17
18 public static void saveerror(exception ex,httpcontext hc,httprequest hr)
19 {
20 string temp ;
21 streamwriter sw ;
22
23 //如果存在文件
24 if(file.exists([email protected]"/error.txt"))
25 {
26 sw = file.appendtext([email protected]"/error.txt") ;
27 temp = datetime.now.tostring() + "------------------------------------------------------------------------------------/n";
28 temp += "錯(cuò)誤消息:" + ex.message +"/n";
29 temp += "導(dǎo)致錯(cuò)誤的應(yīng)用程序或?qū)ο蟮拿Q(chēng):" + ex.source +"/n";
30 temp += "堆棧內(nèi)容:" + ex.stacktrace +"/n";
31 temp += "引發(fā)異常的方法:" + ex.targetsite +"/n";
32 temp += "錯(cuò)誤頁(yè)面" +hr.rawurl + "/n/n";
33
34 sw.writeline(temp) ;
35 sw.close() ;
36 }
37 }
38
新聞熱點(diǎn)
疑難解答
圖片精選