ELMAH is not part of ASP.NET MVC 2

I can’t understand what I'm doing wrong here, trying to use ELMAH in my MVC 2 application and it is not writing anything.

Here is what I have in my web.config (relevant parts)

<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> <elmah> <security allowRemoteAccess="0" /> <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ELMAH.SqlServer" /> <!-- <errorMail from=" youremail@example.com " to=" youremail@example.com " cc="" subject="Elmah Error" async="true" smtpPort="25" smtpServer="[EmailServerName]" userName="" password="" /> <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" /> --> </elmah> <connectionStrings> ... <add name="ELMAH.SqlServer" connectionString="data source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ELMAH_Logging.mdf;Integrated Security=SSPI;Connect Timeout=30;User Instance=True;" providerName="System.Data.SqlClient"/> </connectionStrings> <system.Web> <httpHandlers> <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> ... </httpHandlers> <httpModules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> ... </httpModules> </system.Web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true"> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> </modules> <handlers> <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> ... </handlers> </system.webServer> 

Then, using the DotNetDarren.com code, but no matter what I do, are the exceptions not logged?

+4
source share
3 answers

Elmah fails if it cannot log errors ... Re-check all ur connection strings used by elmah, you can see the problems there.

Here the table script is used to create the DB table

 CREATE TABLE [dbo].[ELMAH_Error]( [ErrorId] [uniqueidentifier] NOT NULL, [Application] [nvarchar](60) NOT NULL, [Host] [nvarchar](50) NOT NULL, [Type] [nvarchar](100) NOT NULL, [Source] [nvarchar](60) NOT NULL, [Message] [nvarchar](500) NOT NULL, [User] [nvarchar](50) NOT NULL, [StatusCode] [int] NOT NULL, [TimeUtc] [datetime] NOT NULL, [Sequence] [int] IDENTITY(1,1) NOT NULL, [AllXml] [varchar](max) NOT NULL, CONSTRAINT [PK_ELMAH_Error] PRIMARY KEY NONCLUSTERED ( [ErrorId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO ALTER TABLE [dbo].[ELMAH_Error] ADD CONSTRAINT [DF_ELMAH_Error_ErrorId] DEFAULT (newid()) FOR [ErrorId] 
+5
source

I'm not sure if this will help you, but I came across the same problem with my first attempt to include ELMAH in my site. Firstly, I could not even see the error screen, and secondly, as soon as I sorted, no errors were reported. Both of them were caused by missing partitions from system.WebServer . I am using MVC3.0 website (recently converted from 2.0). The only difference that I really see between my configuration and yours is that you do not have preCondition = "integratedMode" in the system.WebServer handler section (see below). Maybe this is causing you problems?

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

EDIT

Sorry my original idea didn't help - just a few more thoughts:

  • What version of ELMAH did you download (x86 or x64?) And which version of CPU are you building? You tried to configure the build processor for the same version that you downloaded.
  • Do you have "OnError" processing inside your global.asax, if so, what happens if you delete it?
  • Finally, did you try to create an empty MVC project with ELMAH enabled only to make sure that you can do it correctly.
0
source

I will need to repeat Paul preCondition, but I also have preCondition="managedHandler" in the modules section for each entry.

I also use allowRemoteAccess="1" in the elmah security group, but I blocked the path so that only authenticated users can access the page through a controller call.

I noticed that the XML error log entry is commented out. Does it even work through XML mode or SQL? I know, when I first started working, I had to work in XML mode until I handled the problems with the connection chain and database schema that I had.

You can also run full / medium trust issues depending on deployment, but I think you get elmah exceptions in these situations. Have you tried to see the event log on the machine? It also helped me deal with the growing pains that I had.

Finally, I just noticed this in the January 14 change summary: http://code.google.com/p/elmah/source/detail?r=782 pointing to ELMAH - 404 Error Filtering , which just says the ErrorFilter module must be registered last in order for filtering to work properly. You did not insert filter configuration parameters, so I doubt that this is applicable, but the registered order things matter, apparently, therefore, maybe there is some relation.

0
source

Source: https://habr.com/ru/post/1335487/


All Articles