asp.net mvc - Elmah not logging 404 errors after third folder, and 403 errors at all -
continuing previous question, handle custom errors in mvc5 app using:
<system.webserver> <httperrors errormode="custom" existingresponse="replace"> <remove statuscode="404"/> <error statuscode="404" path="/errors/notfound" responsemode="executeurl" /> <remove statuscode="403"/> <error statuscode="403" path="/errors/notfound" responsemode="executeurl" /> <remove statuscode="500"/> <error statuscode="500" path="/errors/servererror" responsemode="executeurl" /> </httperrors> ... </system.webserver>
this enabled me show custom 404 error page after 3rd folder (e.g. site.com/a/b/c/nothing-here). yet, elmah not logging these errors. true 403 errors. questions are:
- is there way make elmah handle server errors regardless of being thrown mvc app itself?
- if not, since
/errors/notfound
executed, can add log action. there way tell if elmah handled error (or thrown mvc app)?
the problem here is, elmah logs uncaught exceptions. in code, mvc handling errors using custom errors configuration.
if still want log these exceptions, can implement iexceptionfilter in mvc , manually log elmah:
public class elmahexceptionlogger : iexceptionfilter { public void onexception (exceptioncontext context) { if (context.exceptionhandled) { errorsignal.fromcurrentcontext().raise(context.exception); } } }
Comments
Post a Comment