Is it possible to use ELMAH in a SharePoint environment?
Asked Answered
C

4

10

Has anyone integrated ELMAH into their SharePoint environment?

I suppose it's possible as it's all ASP.net, but I just wondered if anyone had done it and if there's a walk through on how to achieve it?

Canner answered 6/5, 2009 at 14:12 Comment(0)
C
6

We use ELMAH in our MOSS 2007 environment. Since ELMAH uses HttpHandlers and is set up via the web.config, activating it was a cinch. Just add the ELMAH stuff to the web.config for the application that you're running inside SharePoint.

If you want ELMAH to report errors at a level higher than your custom application, then add it to the SharePoint web.config.

Correlative answered 6/5, 2009 at 14:16 Comment(3)
excellent stuff! thanks. So if you don't catch an exception yourself in code it will move up the pipeline until ELMAH catches and logs it?Canner
Yep, that's exactly what happens. You can also log handled exceptions in ELMAH as well.Correlative
Where have you deployed your dll to? I'd like to deploy to the GAC to cover all our websites.Canner
E
9

One thing that IS important when setting up ELMAH, or most HTTPModules in Sharepoint is that they need to be at the beginning of the httpModules section. Otherwise SharePoint will essentially swallow the exception and ELMAH functionality will not be invoked

Works

<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....

Does not work

<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"/>
Elanaeland answered 28/7, 2009 at 18:26 Comment(0)
C
6

We use ELMAH in our MOSS 2007 environment. Since ELMAH uses HttpHandlers and is set up via the web.config, activating it was a cinch. Just add the ELMAH stuff to the web.config for the application that you're running inside SharePoint.

If you want ELMAH to report errors at a level higher than your custom application, then add it to the SharePoint web.config.

Correlative answered 6/5, 2009 at 14:16 Comment(3)
excellent stuff! thanks. So if you don't catch an exception yourself in code it will move up the pipeline until ELMAH catches and logs it?Canner
Yep, that's exactly what happens. You can also log handled exceptions in ELMAH as well.Correlative
Where have you deployed your dll to? I'd like to deploy to the GAC to cover all our websites.Canner
C
0

There is no magic to it, just hook it up like you would on any other ASP.NET site.

Conlen answered 6/5, 2009 at 14:13 Comment(0)
S
0

Following are the config entries that needs to added in web.config of the SharePoint web application

Add under configsection

 <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>

Add connectionstring section

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

</connectionStrings>

Add elmah section just below the connectionstring section

<elmah>

  <security allowRemoteAccess="0" />

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

Add handler and module entry in httphandlers and httpmodules section under system.web

  <httpHandlers>

      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>

   </httpHandlers>

   <httpModules>

      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
    </httpModules>

Add handler and module entry in handlers and modules section under system.webserver

    <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>

Please refer below link for elmah implementation in sharepoint

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

Sassenach answered 2/8, 2014 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.