Asp.net mvc exception tracking

I am trying to send an exception caught on the controller to the trace.axd page, but I cannot figure out how to figure it out. I have

<trace enabled="true" localOnly="false" mostRecent="true" pageOutput="false" /> 

in web.config, and my intuitive reaction to exception is

 catch (Exception e) { ViewData["error"] += "Is not number!"; Trace.TraceError(e.ToString()); Trace.TraceError(e.StackTrace); return View(); } 

However, I cannot find any of these lines on the trace.axd page. So how to get them?

Secondly, I want to ask how can I turn off tracing, and not problems (that is, those that I personally do not send using any method), since they simply flood my track and delete these random error reports before anyone else then he notices them.

Thanks in advance.

+4
source share
1 answer

I think your problem is that you are using the System.Diagnostics.Trace class instead of the ASP.NET tracing mechanism, and you did not configure the tracing of trace messages on trace.axd . Try using the Controller.HttpContext.Trace object for tracing.

Alternatively, try routing System.Diagnostics.Trace to an ASP.NET trace by adding the following snippet to web.config :

 <system.diagnostics> <trace> <listeners> <add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </listeners> </trace> </system.diagnostics> 
+4
source

All Articles