我正在使用Elmah来捕获应用程序中未处理的异常。当Elmah写一个日志条目时,我想运行一个自定义代码。
我创建了一个从Elmah.SqlErrorLog派生的自定义ErrorLog,并在web配置文件中设置了我的ErrorLog。
namespace Test.Logging{公共类MySqlErrorLog : Elmah.SqlErrorLog {公共MySqlErrorLog(string connectionString):base(connectionString) {
}
public override string Log(Elmah.Error error)
{
return base.Log(error);
//custom code
}
}}
<errorLog type="Test.Logging.MySqlErrorLog, Test" connectionStringName="elmah-sqlserver" />这看起来很好,但什么也没发生。数据库中没有日志记录。
有人能帮我吗?
感谢高级!
发布于 2013-11-01 20:45:44
不知道你有没有解决过这个问题。在尝试解决类似问题时发现了您的帖子。结果是我遗漏了构造器。在你的例子中,我认为是你的命名空间错了,命名空间是Test.Logging,而不仅仅是测试。
因此,web.config行应该是:
<errorLog type="Test.Logging.MySqlErrorLog, Test.Logging" connectionStringName="elmah-sqlserver" />https://stackoverflow.com/questions/18598095
复制相似问题