ELMAH installed via elmah.bootstrapper not logging purposely thrown error.

219 views
Skip to first unread message

Adrian Simmons

unread,
Nov 29, 2017, 3:03:51 PM11/29/17
to ELMAH
I used NuGet to install elmah.bootstrapper and configured an action in the Home controller as the following

public ActionResult Error() => throw new HttpException(message: "Testing ELMAH");

but I don't get anything coming through in the logs when I trigger the action.

I have an excessive amount of 404 errors logged from what look like penetration attacks though.

The application was created by using the ASP.NET MVC template in Visual Studio 2017 and all NuGet packages have been updated. The application targets 4.7 which is something I changed in the project properties.

Is there something else I'm supposed to do to configure ELMAH?

Atif Aziz

unread,
Nov 29, 2017, 4:20:27 PM11/29/17
to el...@googlegroups.com
Does it log anything if you use the test exception procedure built-into ELMAH? For example, if your error log is accessible at the URL http://www.example.com/errorlog then try and visit http://www.example.com/errorlog/test. It should generate an error with the message, “This is a test exception that can be safely ignored.” If you return to the error log view, do you see a test exception logged?

- Atif


--
You received this message because you are subscribed to the Google Groups "ELMAH" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elmah+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adrian Simmons

unread,
Nov 30, 2017, 12:24:39 PM11/30/17
to ELMAH
HostCodeTypeErrorUserDateTime
EC2AMAZ-A1C7CCL0TestThis is a test exception that can be safely ignored. Details…ar11/30/20175:23 PM
To unsubscribe from this group and stop receiving emails from it, send an email to elmah+un...@googlegroups.com.

Adrian Simmons

unread,
Nov 30, 2017, 12:28:51 PM11/30/17
to ELMAH
Cool little feature, in answer to your question yes it does!

This application is deployed on AWS but I doubt very much that matters.

It appears that by default the template that you get in VS2017 handles errors and is custom, hence returning you to a view with a few words about an error having happened. The odd thing is though that the web.config doesn't have an errors sections!

Does this mean due to the above that there is some more configuration that needs to happen?

Atif Aziz

unread,
Nov 30, 2017, 5:20:00 PM11/30/17
to el...@googlegroups.com
Since the test error is getting logged, I think we can conclude that ELMAH is working.

Does this mean due to the above that there is some more configuration that needs to happen?

Probably. You might want to check out the Elmah.MVC package/project (separately and independently) maintained, for pointers and help.

To unsubscribe from this group and stop receiving emails from it, send an email to elmah+unsubscribe@googlegroups.com.

Adrian Simmons

unread,
Nov 30, 2017, 6:03:45 PM11/30/17
to ELMAH
So I just add the elmah.mvc package and then put all those settings in the web.config?

What is the point of bootstrapper?

Adrian Simmons

unread,
Nov 30, 2017, 7:36:04 PM11/30/17
to ELMAH
My previous reply was uncalled for even if I am frustrated, that is no excuse please accept my sincere apologies.

For me there are two very pertinent points in using elmah.bootstrapper!!
  1. The Athz file, what a great way to configure the authorisation for the log page.
  2. App_Data\errors\xmlstore for an easy way to enable XML logging.
I have a question that I hope you will answer.

Given that it is now 2017 and that you have recently updated elmah.bootstrapper do you think that the ElmahHandledErrorLoggerFilter solution as proposed by Ivan Zlatev is an acceptable way to have the exceptions that get handled by CustomErrors be routed to ELMAH or is there a better way now with elmah.bootstrapper?

Atif Aziz

unread,
Dec 2, 2017, 8:16:09 AM12/2/17
to el...@googlegroups.com
So I just add the elmah.mvc package and then put all those settings in the web.config?

The Elmah.MVC package is a separate project and I cannot advise you on it since I've never used it. It would be best to ask this question there.

To unsubscribe from this group and stop receiving emails from it, send an email to elmah+unsubscribe@googlegroups.com.

Atif Aziz

unread,
Dec 2, 2017, 8:27:15 AM12/2/17
to el...@googlegroups.com
What is the point of bootstrapper?

ELMAH Bootstrapper modernises and streamlines the use of ELMAH with ASP.NET 4.x for the 80% case. It has nothing to do with ASP.NET MVC, which is layered on top of ASP.NET. I have never supported ASP.NET MVC directly because I have never needed to use it and so would only pretended to know what I am doing. :) When someone has trouble with ELMAH and ASP.NET MVC, I usually point them to Elmah.MVC hoping that its maintainers will be in a better position to help.

- Atif

To unsubscribe from this group and stop receiving emails from it, send an email to elmah+unsubscribe@googlegroups.com.

Atif Aziz

unread,
Dec 2, 2017, 9:05:39 AM12/2/17
to el...@googlegroups.com
Given that it is now 2017 and that you have recently updated elmah.bootstrapper do you think that the ElmahHandledErrorLoggerFilter solution as proposed by Ivan Zlatev is an acceptable way to have the exceptions that get handled by CustomErrors be routed to ELMAH or is there a better way now with elmah.bootstrapper?

Do you mean from the following blog entry?


If so then it seems to me that it does the job though I would change the call to ErrorSignal.Raise to also send the HTTP context for more thorough logging. I did a quick test with the setup you described and I have shared my steps in the following repo & branch:


You can clone just the branch using:

git clone -b thread/6baNilOnWyk --single-branch https://github.com/elmah/discuss.git

In 960322f, I started with an ASP.NET MVC web application created from the template in VS 2017. I targeted .NET Framework 4.6.2 instead of 4.7 because I don't have the latter and the former was the highest version on my machine.

In a561083, I added ELMAH via ELMAH Bootstrapper and in 6f08d86 I added the App_Data\errors\xmlstore directory so ELMAH Bootstrapper would use the XmlFileErrorLog.

In 4788da0, I added the error action from your initial post. At this point, all error logging was working as expected. When I did the custom error pages setup in d219af4, the error action stopped logging. All other errors, that didn't go via the ASP.NET MVC route, were still getting logged, like a 404 or the logging test built-into ELMAH. In d602ea4, I added an improved version of Ivan's ElmahHandledErrorLoggerFilter and the exception thrown by the error action was logging again. The improvement I made basically passes the HTTP context to ErrorSignal.Raise in addition to the exception to be logged.

There is no better way to do it with ELMAH Bootstrapper as it has not dependency on ASP.NET MVC.

Hope this helps.

- Atif


To unsubscribe from this group and stop receiving emails from it, send an email to elmah+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages