Elmah not logging 404 (missing files / images)

2019-07-12 15:50发布

问题:

For some reason emlah is not logging missing images in my MVC3 app. Everything else like 'missing action' wrong url is ok. what could be the cause? thanks

EDIT:

I am running Integrated Mode and am NOT using built-in VS IIS.

EDIT 2:

Doesn't seem to log missing images if the images are mapped via virtual directory:

回答1:

That's because you are not running in IIS integrated pipeline mode. If you are testing this inside the Visual Studio's built-in web server (Cassini) or IIS 6.0 or IIS 7.0 classic mode, images are served directly by the web server and not through the ASP.NET environment. So since, ELMAH is an ASP.NET handler, it has no way of knowing about those images.

You could switch to using IIS Express locally and when you ship use IIS 7.0 integrated pipeline mode. Then you will get logs for not found static resources such as images.