【问题标题】:Elmah works on localhost, but not on production?Elmah 适用于 localhost,但不适用于生产?
【发布时间】:2013-07-13 22:07:31
【问题描述】:

在我的 ASP.NET MVC 3 应用程序中,我配置了 Elmah,然后配置了 Elmah.MVC 以记录错误。在本地主机(Windows 7,IIS 6.1)上运行时,这两个日志都很好。在生产服务器(2008 R2,IIS 6.1)上,不会记录任何错误。我可以毫无问题地浏览到站点中的 /elmah 目录(我现在允许远程访问。)我已经为 XML 日志记录的文件夹设置了适当的权限,但没有记录任何内容。我回溯使用“内存中”记录器,仍然没有日志。我已确保在 system.web 和 system.webserver 中正确引用了模块和处理程序。

我浏览了很多与 Elmah 配置问题、权限等相关的帖子,但尚未找到导致此问题的原因。

生产服务器上是否还有其他与 Elmah 相关的安全/权限问题?还有什么可能导致这种情况?

【问题讨论】:

  • 这仍然是真实的吗?我可以假设,您的生产机器的配置有问题。也许设置了一些 iis 扩展来捕获所有错误,所以 elmah 无法捕获任何东西..

标签: asp.net-mvc-3 elmah production-environment elmah.mvc


【解决方案1】:

确保您没有在文件夹上选中“只读”。谢谢

【讨论】:

    【解决方案2】:

    不确定这是否仍然是最新的,但我遇到了类似的问题:当你有 customErrors mode="Off" 但如果你将 customErrors 更改为 RemoteOnly 那么它只有在您在本地访问该网站时才有效。 解决方案是在 FilterConfig 部分添加一个新的 Elmah 过滤器,以确保无论 customErrors 模式如何,elmah 都会始终记录错误。这是详细信息:http://forums.asp.net/t/1687875.aspx?Elmah+Error+Log+is+not+working+my+production+Server

    这里是代码 sn-p(感谢帖子上的人):

    public class FilterConfig {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters) {
            filters.Add(new ElmahHandledErrorLoggerFilter());
            filters.Add(new HandleErrorAttribute());
        }
    }
    
    public class ElmahHandledErrorLoggerFilter : IExceptionFilter {
        public void OnException(ExceptionContext context) {
            //if (context.ExceptionHandled) // Log only handled exceptions, because all other will be caught by ELMAH anyway.
            //We want elmah to log ALL exceptions
            ErrorSignal.FromCurrentContext().Raise(context.Exception);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-18
      • 1970-01-01
      • 1970-01-01
      • 2018-08-22
      • 2018-09-17
      • 2016-11-08
      • 1970-01-01
      • 2022-11-24
      相关资源
      最近更新 更多