Installed Install-Package Elmah.MVC from Nugate in MVC 5 Code first .
I have been researching for hours to fix this but cannot get it to work. ELMAH does not log errors to the DB. I have went over multiple resources such as the links at the bottom but have had no success. I have the package installed, I have it pointing
to the DB string name ErrorLog, I have the web.config elmah setting set to Elmah.SqlErrorLog, Elmah pointing to the connection string name , but it still errors does not store in db . Any help?
With that said, you config looks fine (I've validated it with this
web.config validator for future help troubleshooting). The problem probably is, that something else is handling exceptions, before ELMAH is invoked. Do you show a custom error page, declare your own HandleError-like attribute, or similar? I recommend you
to read through this: Demystifying ASP.NET MVC 5 Error Pages and Error Logging.
Member
5 Points
77 Posts
Elmah showing No records though I get errors in MVC 5 code first
Aug 29, 2018 11:12 AM|nagapavanich|LINK
Installed Install-Package Elmah.MVC from Nugate in MVC 5 Code first .
I have been researching for hours to fix this but cannot get it to work. ELMAH does not log errors to the DB. I have went over multiple resources such as the links at the bottom but have had no success. I have the package installed, I have it pointing to the DB string name ErrorLog, I have the web.config elmah setting set to Elmah.SqlErrorLog, Elmah pointing to the connection string name , but it still errors does not store in db . Any help?
https://elmah.github.io/a/mvc/
http://www.andyfrench.info/2014/07/configuring-elmah-to-use-sql-server.html
added all required webconfig tags below my config
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<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="ConnectionString" connectionString="Server=xxx;Uid=xx;Pwd=xxx;Database=IBAC;Connect TImeout=120;Pooling=True;Max Pool Size=200;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="AdminFromEmailAddress" value="myemailId" />
<add key="SmtpClientclientPath" value="smtp.gmail.com" />
<add key="SmtpClientclientPathPort" value="587" />
<!-- Your SMTP Server IP -->
<add key="userName" value="myusername" />
<add key="password" value="mypassword" />
<add key="elmah.mvc.disableHandler" value="false" /><add key="elmah.mvc.disableHandleErrorFilter" value="false" /><add key="elmah.mvc.requiresAuthentication" value="false" /><add key="elmah.mvc.IgnoreDefaultRoute" value="false" /><add key="elmah.mvc.allowedRoles" value="*" /><add key="elmah.mvc.allowedUsers" value="*" /><add key="elmah.mvc.route" value="elmah" /><add key="elmah.mvc.UserAuthCaseSensitive" value="true" /></appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<authentication mode="Forms">
<forms defaultUrl="/Home/mypage" loginUrl="/Home/Index" slidingExpiration="true" timeout="2880"></forms>
</authentication>
<httpHandlers>
<add verb = "POST,GET,HEAD" path = "elmah.axd" type = "Elmah.ErrorLogPageFactory, Elmah"/>
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<!--<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>-->
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" /> <!--1GB-->
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false" /><modules>
<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>
<handlers>
<add name = "Elmah" verb = "POST,GET,HEAD" path = "elmah.axd" type = "Elmah.ErrorLogPageFactory, Elmah"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<elmah>
<!--. If allowRemoteAccess value is set to 0, then the error log web page can only be viewed locally. If allowRemoteAccess attribute is set to 1 then the error log web page is enabled for both remote and local visitors.-->
<!--add this-->
<security allowRemoteAccess="0" />
<!-- DefaultConnection is the name of database connection string -->
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="IBAC_ConnectionString" applicationName="IBAC" />
<!--add this-->
</elmah></configuration>
created table ELMAH_Error and 3 sps ELMAH_GetErrorsXml,ELMAH_GetErrorXml,ELMAH_LogError
also added in controller Elmah.ErrorSignal.FromCurrentContext().Raise(dbEx)
but every time i get "No records" in http://localhost:port/elmah.axd no data inserted in table ELMAH_Error in sql server 2008
My IIS is IIS7.5 in development server and Vs 2013 Community.Please suggest
Member
50 Points
19 Posts
Re: Elmah showing No records though I get errors in MVC 5 code first
Aug 31, 2018 05:41 AM|ThomasArdal|LINK
Since you are using the Elmah.MVC NuGet package, you need to follow the guide from that package. Check out https://github.com/alexbeletsky/elmah-mvc for details.
With that said, you config looks fine (I've validated it with this web.config validator for future help troubleshooting). The problem probably is, that something else is handling exceptions, before ELMAH is invoked. Do you show a custom error page, declare your own HandleError-like attribute, or similar? I recommend you to read through this: Demystifying ASP.NET MVC 5 Error Pages and Error Logging.