如何维护ui页面错误的错误日志表 [英] how to maintain error log table for the ui page errors

查看:97
本文介绍了如何维护ui页面错误的错误日志表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们打开任何UI页面并且它收到任何错误意味着错误应该保存到我们在数据库中维护的错误日志表中如何执行此操作。

if we open any UI page and it is getting any error means that error should be saved in to the error log table which we are maintaining in the database how to do this .

推荐答案

如果要记录错误,请将代码放入 try-catch 块并在 catch 语句中记录错误。



伪代码示例;

If you want to log the errors put your code into try-catch block and log the error in catch statement.

An example pseudo code;
try
{
 //your code in the page
}
catch(Exception ex)
{
  //open a DB connection
  //Insert the exception details to your table
  // close your connection after inserting
}





您也可以使用 global.asax 文件。

以下是一些示例链接,可以给您一个想法:

使用ASP.NET和创建简单的错误日志文件C# [ ^ ]

使用ASP.NET运行状况监视(C#)记录错误详细信息 [ ^ ]

事件和错误记录 [ <小时ef =http://www.c-sharpcorner.com/UploadFile/scottlysle/EventAndErrorLogging12152006003023AM/EventAndErrorLogging.aspx\"target =_ blanktitle =New Window> ^ ]





请注意这里。当您使用try-catch时,它会吞下异常,因此您可能希望通过客户端消息框或类似的方式通知用户。



祝您好运,

OI



You can also use your global.asax file as well.
Here are some example links to give you an idea:
Create Simple Error Log Files using ASP.NET and C#[^]
Logging Error Details with ASP.NET Health Monitoring(C#)[^]
Event and Error Logging[^]


Beware here though. When you use try-catch it will swallow the exception so you might want to notify the user with a client-sided message box or something similar.

Good luck,
OI


这篇关于如何维护ui页面错误的错误日志表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆