Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use ELMAH in a SharePoint environment?

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?

like image 415
Rob Avatar asked May 06 '09 14:05

Rob


People also ask

How to use ELMAH?

How to use ELMAH? Create a new MVC application. On the File menu, click New >> Project. In the New Project dialog box, under Project types, expand "Visual C#", and then click "Web" and in the Name box, type "DemoELMAH".

How do I set up ELMAH in Visual Studio?

The easiest way of setting up ELMAH is through NuGet. Run the following command: ... Or add ELMAH by right-clicking on References: Click Install and ELMAH is installed in your project. A lot of configuration has been setup in your web.config, but for now just start your web project.

How does ELMAH log exceptions?

Unlike other logging frameworks ELMAH will, when configured in its most simple form, log every exception automatically. Sure, there’s an API you can use to log custom errors, but most people only use the automatic part.

Where can I find ELMAH’s Details view?

ELMAH shows the most important variables in the table, but if you want the full picture, you can click the Details… link at the end of the error message. This will show ELMAH’s details view:


2 Answers

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"/>
like image 144
John Ptacek Avatar answered Nov 24 '22 08:11

John Ptacek


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.

like image 43
Robert S. Avatar answered Nov 24 '22 08:11

Robert S.