【发布时间】:2009-05-06 14:12:03
【问题描述】:
是否有人将ELMAH 集成到他们的 SharePoint 环境中?
我想这是可能的,因为它都是 ASP.net,但我只是想知道是否有人做过,是否有关于如何实现它的演练?
【问题讨论】:
标签: sharepoint moss elmah
是否有人将ELMAH 集成到他们的 SharePoint 环境中?
我想这是可能的,因为它都是 ASP.net,但我只是想知道是否有人做过,是否有关于如何实现它的演练?
【问题讨论】:
标签: sharepoint moss elmah
在设置 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"/>
【讨论】:
我们在 MOSS 2007 环境中使用 ELMAH。由于 ELMAH 使用 HttpHandlers 并且是通过 web.config 设置的,因此激活它很容易。只需将 ELMAH 内容添加到您在 SharePoint 中运行的应用程序的 web.config。
如果您希望 ELMAH 报告比您的自定义应用程序更高级别的错误,请将其添加到 SharePoint web.config。
【讨论】:
它没有魔法,只需像在任何其他 ASP.NET 网站上一样连接它。
【讨论】:
以下是需要在 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
【讨论】: