是否可以使用ELMAH执行以下操作?
logger.Log(" something");
我正在做这样的事情:
try 
{
    // Code that might throw an exception 
}
catch(Exception ex)
{
    // I need to log error here...
}
ELMAH不会自动记录此异常,因为它已被处理.
我刚开始使用ELMAH并且是粉丝.我的团队支持大量的Web应用程序,我特别兴奋的是ELMAH允许我们将每个应用程序的异常保存到同一个MS SQL数据库表中.
我们还支持一些控制台,DLL和桌面应用程序.是否可以使用ELMAH DLL将这些应用程序中的异常记录到同一位置?
我有一个MVC 4 Web应用程序。使用ELMAH和Elmah.Contrib.WebApi,可以完美记录我的控制器或API控制器(或其底层服务)中发生的任何异常。
我遇到麻烦的地方是手动记录错误。具体来说,在Global.asax中,我有很多初始化代码(设置自动映射器等)。为了捕获初始化代码中可能发生的问题,我具有以下内容:
 protected void Application_Start()
    {
        try
        {
            ControllerBuilder.Current.SetControllerFactory(new ErrorHandlingControllerFactory());
            GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            GlobalConfiguration.Configuration.Filters.Add(new ElmahHandleErrorApiAttribute());
            AutoMapperConfiguration.Configure();
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
            DatabaseConfig.Initialize();
            SecurityConfig.Initialize();
        }
        catch (Exception e)
        {
            var context = HttpContext.Current;
            var signal = ErrorSignal.FromContext(context);
            if (signal != null)
            {
                signal.Raise(e, context);
            }
        }
    }
ELMAH永远不会记录在“ catch”块内捕获的任何异常。但是,我知道ELMAH正在工作,因为从此以后,任何控制器内部都会记录任何其他异常。因此,我排除了web.config之类的问题。
有什么建议么?谢谢。