c# - Elmah.MVC setup -


I'm getting up to an MVC 5 WebAPI app and trying to run with Elma I think starting all the docs And finished with "It's set up through nuget" and just think that it will cover, but I'm clearly missing something I have installed Elmah. Through the MVC 2.1.1 newsletter, and I'm able to see the error log / Elmoh. I am capable of requesting an illegal route and see that the 409 error is being logged by Elma, even with the launch of custom orders However, if I generate an arbitrary error within a controller, or during the controller's urgency, nothing is found in Elma. For example:

I can call this all day and nothing in Elma log shows Adding the standard handlair attribute does not change anything, and a little bit of documents is clearly obvious. That I do not need to create a custom handler feature

I use En for DI, and so on, if I break a dependency bond, I get a good error like this:

  {Message: "An error has occurred." Exception message: "An error occurred while trying to create a controller type 'health controller.' Make sure that the controller has a public constructor with no parameter." ...}   

But there is nothing in Elmaah, in that case either anyone logs in.

I believe in both cases because this is because MVC is dealing with those errors (formatting exceptions as JSON, etc.) for me and they are not passing in Elmah how do I Can I configure so that there is no exception in any controller, which is logged by Elmaha?

figure out This is the same as the old exception filter system, but as a more global exception filter only works with uncontrolled exceptions from a specific controller and there are no errors which may crop upstream in the stack. First of all, I needed a simple exception logger to pass the exceptions of Elma:

  Public category ElmahExceptionLogger: ExceptionLogger {public override zero log (exception logo context context) {Elma. Erlog.Get Default (The new Elma Error (References Exposure));}}   

Then WebApiConfig.cs:

  public Fixed Zero Registration (HTTP Configuration Config) {// Web API Routes config.MapHttpAttributeRoutes (); config.SServices.Add (IExceptionLogger), New Elm Exception Logger ())}   

It requires the latest and greatest MVC / WebAPI (5.1.1 currently).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -