views:

332

answers:

3

Has anyone intergated 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.

A: 

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

Lars Mæhlum
+1  A: 

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.

Robert S.
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?
Rob
Yep, that's exactly what happens. You can also log handled exceptions in ELMAH as well.
Robert S.
Where have you deployed your dll to? I'd like to deploy to the GAC to cover all our websites.
Rob
+3  A: 

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"/>
John Ptacek
excellent advice, thanks!
Rob