I have set Elmah for an ASP.NET MVC 5 project to handle exceptions and save them in database (Oracle).
我为ASP设置了Elmah。NET MVC 5项目处理异常并将其保存在数据库中(Oracle)。
Now I've encountered a situation where Elmah can fail to log exceptions in database and cause an exception by itself because database being down, connection string changes etc.
现在我遇到了这样一种情况:Elmah无法在数据库中记录异常,并且由于数据库宕机、连接字符串更改等原因导致异常本身。
I tried this:
我试着这样的:
try
{
Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Testing Elmah exception handling"));
} catch (Exception ex)
{
LogException(ex);
}
but LogException(ex) is never executed.
但是从未执行LogException(ex)。
In LogException I have implemented a custom logger that also writes in database.
在LogException中,我实现了一个自定义日志记录器,它也在数据库中写入。
1 个解决方案
#1
1
Elmah writes failures in Windows Event logs on server in fallback scenarios. That means, if Elmah fails to write exception/ event in the configuration option you might have selected (i.e., Database, file system, or whatever custom option configuration), it will write to the Windows Event Logs on the server where the application is running.
Elmah在回退场景中在服务器上写Windows事件日志中的失败。这意味着,如果Elmah未能在您可能选择的配置选项中写入异常/事件(例如。它将写入应用程序正在运行的服务器上的Windows事件日志。
As an additional note, in case of NLB (Load balance) environments, the exception would be logged in Windows event log of one of the servers from where a particular request is being served, and not all server where the application is running).
另外要注意的是,在NLB(负载平衡)环境中,异常将记录在服务特定请求的服务器的Windows事件日志中,而不是应用程序运行的所有服务器)。
#1
1
Elmah writes failures in Windows Event logs on server in fallback scenarios. That means, if Elmah fails to write exception/ event in the configuration option you might have selected (i.e., Database, file system, or whatever custom option configuration), it will write to the Windows Event Logs on the server where the application is running.
Elmah在回退场景中在服务器上写Windows事件日志中的失败。这意味着,如果Elmah未能在您可能选择的配置选项中写入异常/事件(例如。它将写入应用程序正在运行的服务器上的Windows事件日志。
As an additional note, in case of NLB (Load balance) environments, the exception would be logged in Windows event log of one of the servers from where a particular request is being served, and not all server where the application is running).
另外要注意的是,在NLB(负载平衡)环境中,异常将记录在服务特定请求的服务器的Windows事件日志中,而不是应用程序运行的所有服务器)。