Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Elmah logging?

I am using Elmah.MVC 2 with MVC3, ASP.NET 4.5 on Azure Websites.

I have set it up to log, via the web.config, to XML files on the webserver. This all works. However I want to stop it temporarily, as I believe it may be slowing the web server, since it is taking up time writing these error files. I plan to log to SQL Server. But for now I need to stop Elmah.

My Web.config Elmah sections are :

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

and

<add key="elmah.mvc.disableHandler" value="true" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="true" />
<add key="elmah.mvc.IgnoreDefaultRoute" value="false" />
<add key="elmah.mvc.allowedRoles" value="Admin" />
<add key="elmah.mvc.allowedUsers" value="Admin" />
<add key="elmah.mvc.route" value="elmah" />

and

<httpModules>
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>

and

<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>

and

  <elmah>
    <security allowRemoteAccess="yes" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="myDatabaseCS" />
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
    </elmah>
</configuration>

I thought this line stopped it:

    <add key="elmah.mvc.disableHandler" value="true" />

But alas not. However I cannot get to the Elmah page ie /Elmah just returns me to the login page.

How can I stop Elmah logging?

Thanks.

EDIT 1:

it may be to do with this in Global.asa:

//filters.Add(new ElmahHandledErrorLoggerFilter());
filters.Add(new HandleErrorAttribute());

THe first line is commented out as I do not believe it is required in V2. All error handling is now merged with Elmah I believe.

like image 314
SamJolly Avatar asked Aug 19 '14 21:08

SamJolly


1 Answers

Just remove the <errorLog> elements from your <elmah> section. Or comment it out. This will disable the logging functionality, and all you have to do to restore functionality when you want it is add those <errorLog> elements back in again. This way, you don't have to remove any of the core Elmah components that could lead to problems later on when you want to restore functionality, particularly if you miss something.

like image 160
Chris Paton Avatar answered Sep 18 '22 07:09

Chris Paton