fea*_*net 12 .net c# error-logging elmah
我对如何使用ELMAH以编程方式记录的错误添加消息感到困惑.
例如:
public ActionResult DoSomething(int id)
{
try { ... }
catch (Exception e)
{
// I want to include the 'id' param value here, and maybe some
// other stuff, but how?
ErrorSignal.FromCurrentContext().Raise(e);
}
}
Run Code Online (Sandbox Code Playgroud)
看来Elmah所能做的就是记录原始异常,我怎样才能记录自己的调试信息?
Jef*_*ata 18
您可以抛出一个新的Exception设置原始内容作为内部异常,ELMAH将记录两者的消息:
catch(Exception e)
{
Exception ex = new Exception("ID = 1", e);
ErrorSignal.FromCurrentContext().Raise(ex);
}
Run Code Online (Sandbox Code Playgroud)
将会呈现
System.Exception: ID = 1 ---> System.NullReferenceException: Object reference not set to an instance of an object.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6962 次 |
| 最近记录: |