ELMAH错误日志,我能登录的消息? [英] Elmah error logging, can I just log a message?
本文介绍了ELMAH错误日志,我能登录的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚安装ELMAH(的https://$c$c.google.com/ p / ELMAH / )为我的ASP.NET应用程序。
是否有可能登陆的消息,而不首先创建一个异常?
赶上(例外五)
{
异常前=新的异常(ID = 1,E);
。ErrorSignal.FromCurrentContext()提高(前);
}
所以是有可能这样做:
ErrorSignal.FromCurrentContext()日志(你好我测试ELMAH);
解决方案
是的,你可以使用ErrorSignal没有抛出异常。
ErrorSignal.FromCurrentContext()提高(新NotSupportedException异常());
有关自定义消息,您可以创建一个自定义异常。
VAR customEx =新的异常(你好我测试ELMAH,新的引发NotSupportedException());
。ErrorSignal.FromCurrentContext()提高(customEx);
I just installed Elmah (https://code.google.com/p/elmah/) for my ASP.NET application. Is it possible to log a message without creating an Exception first?
catch(Exception e)
{
Exception ex = new Exception("ID = 1", e);
ErrorSignal.FromCurrentContext().Raise(ex);
}
So is it possible to do:
ErrorSignal.FromCurrentContext().log("Hello I am testing Elmah");
解决方案
Yes, you can use ErrorSignal without throwing an exception.
ErrorSignal.FromCurrentContext().Raise(new NotSupportedException());
For the custom message, you can create a custom exception.
var customEx = new Exception("Hello I am testing Elmah", new NotSupportedException());
ErrorSignal.FromCurrentContext().Raise(customEx);
这篇关于ELMAH错误日志,我能登录的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文