【问题标题】:Is it possible to use ELMAH in a SharePoint environment?是否可以在 SharePoint 环境中使用 ELMAH?
【发布时间】:2009-05-06 14:12:03
【问题描述】:

是否有人将ELMAH 集成到他们的 SharePoint 环境中?

我想这是可能的,因为它都是 ASP.net,但我只是想知道是否有人做过,是否有关于如何实现它的演练?

【问题讨论】:

    标签: sharepoint moss elmah


    【解决方案1】:

    在设置 ELMAH 或 Sharepoint 中的大多数 HTTPModules 时,重要的一点是它们需要位于 httpModules 部分的开头。否则,SharePoint 将基本上吞下异常并且不会调用 ELMAH 功能

    作品

    <clear />
    <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>  
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
    <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
    <add name="SPRequest" type="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    <add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
         ... Rest of SharePoint modules....
    

    不起作用

    <clear />
    <add name="SPRequest" type="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    <add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
         ... Rest of SharePoint modules....
    <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>  
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
    <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
    

    【讨论】:

      【解决方案2】:

      我们在 MOSS 2007 环境中使用 ELMAH。由于 ELMAH 使用 HttpHandlers 并且是通过 web.config 设置的,因此激活它很容易。只需将 ELMAH 内容添加到您在 SharePoint 中运行的应用程序的 web.config。

      如果您希望 ELMAH 报告比您的自定义应用程序更高级别的错误,请将其添加到 SharePoint web.config。

      【讨论】:

      • 好东西!谢谢。因此,如果您自己没有在代码中捕获异常,它将向上移动直到 ELMAH 捕获并记录它?
      • 是的,就是这样。您还可以在 ELMAH 中记录已处理的异常。
      • 您将 dll 部署到了哪里?我想部署到 GAC 以覆盖我们所有的网站。
      【解决方案3】:

      它没有魔法,只需像在任何其他 ASP.NET 网站上一样连接它。

      【讨论】:

        【解决方案4】:

        以下是需要在 SharePoint Web 应用程序的 web.config 中添加的配置条目

        在配置部分添加

         <configSections>
            <sectionGroup name="elmah">
        
            <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
        
            <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
        
            <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
        
            <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
        
            </sectionGroup>
         </configSections>
        

        添加连接字符串部分

        <connectionStrings>
         <add name="elmah-express" connectionString="Data Source=[server name];Initial Catalog=  [ELMAH_customlogging];User ID=testuser;Password=Welcome1;" />
        
        </connectionStrings>
        

        在连接字符串部分下方添加 elmah 部分

        <elmah>
        
          <security allowRemoteAccess="0" />
        
          <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-express" />
        </elmah>
        

        在 system.web 下的 httphandlers 和 httpmodules 部分添加处理程序和模块条目

          <httpHandlers>
        
              <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
        
           </httpHandlers>
        
           <httpModules>
        
              <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
            </httpModules>
        

        在 system.webserver 下的 handlers and modules 部分添加处理程序和模块条目

            <modules runAllManagedModulesForAllRequests="true">
        
            <remove name="ErrorLog"/>
        
             <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
        
             <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
        
             <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
        
             <add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" preCondition="managedHandler" />
             </modules>
        
             <handlers>
        
             <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
        
             </handlers>
        

        请参阅下面的链接以了解 sharepoint 中的 elmah 实现

        http://sidteche.blogspot.in/2014/08/implement-elmah-custom-logging-in.html

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2010-10-25
          • 1970-01-01
          • 1970-01-01
          • 2016-01-03
          • 2023-02-24
          • 2016-07-03
          • 2016-02-11
          相关资源
          最近更新 更多