Search code examples
web-serviceswcftrace

WCF web service Critical Trace


I have a WCF service I want to trace. I have set the next lines int the Web.Config file:

   <system.diagnostics>
      <sources>
            <source name="System.ServiceModel" 
                    switchValue="Critical, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="traceListener" 
                   type="System.Diagnostics.XmlWriterTraceListener" 
                   initializeData= "C:\Logs\MyCriticalTraces.svclog" />
            </listeners>
         </source>
      </sources>
   </system.diagnostics>

As you can see I just want CRITICAL messages but the File is extremely large (40 Mb every 5 minutes). It keeps getting larger and larger in a few minutes. If I look into the file I see many messages but none seem to be Critical.

I just want to trace the Critical errors, otherwise the file would be impossible to move or open. Any idea about this?


Solution

  • Sorry, I just copied-pasted that tracing code from some forum without knowing what I was doing. Then I realized that the option switchValue was wrong. I mean, I don't need the ActivityTracing log. So the line

    switchValue="Critical, ActivityTracing"
    

    Should be:

    switchValue="Critical"
    

    So the result is this:

       <system.diagnostics>
          <sources>
                <source name="System.ServiceModel" 
                        switchValue="Critical"
                        propagateActivity="true">
                <listeners>
                   <add name="traceListener" 
                       type="System.Diagnostics.XmlWriterTraceListener" 
                       initializeData= "C:\Logs\MyCriticalTraces.svclog" />
                </listeners>
             </source>
          </sources>
       </system.diagnostics>