Search code examples
asp.net-mvcasp.net-mvc-3asp.net-mvc-4asp.net-mvc-5glimpse

How to disable Tracing within a MVC Asp.Net application using Trace.WriteLine and Glimpse?


I use MVC3/ASP.NET 4.5, and use Trace.WriteLine("") type statements in my application which show up in my Glimpse Panel.

However how can I disable Tracing, say when I go into Production. I thought it was:

<system.web>
  <trace enabled="false" />

But this does not work. The tracing comments still faithfully appear in Glimpse.


Solution

  • Unfortunately that trigger is focused on system web's tracing and not Glimpse. We could change things to adhere to that config point, but it doesn't currently.

    Hence the following is what you want in you web.config:

    <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd"> 
        <inspectors>
            <ignoredTypes>
                <add type="Glimpse.Core.Inspector.TraceInspector, Glimpse.Core" />
            </ignoredTypes>
        </inspectors>
    </glimpse>
    

    And if you want the tab do disappear as well, you will want this:

    <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
        <tabs>
            <ignoredTypes>
                <add type="Glimpse.Core.Tab.Trace, Glimpse.Core" />
            </ignoredTypes>
        </tabs>
        <inspectors>
            <ignoredTypes>
                <add type="Glimpse.Core.Inspector.TraceInspector, Glimpse.Core" />
            </ignoredTypes>
        </inspectors>
    </glimpse>