locked
system diagnostic trace listeners RRS feed

  • Question

  • Hello!

    I have some Trace.TraceInformation statements in my WCF service. I would like to obtain both the WCF trace (System.ServiceModel) as well as the output from my Trace statements. The only way I can figure out how to do this is by creating two log files (see below). Is there a way to have my Trace statements included in the svclog xml file created by the XmlWriterTraceListener?

    ------my web.config----

      <system.diagnostics>
         <trace autoflush="true" indentsize="4">
          
            <!-- log TRACE messages-->
            <listeners>
              <add name="lcars_listener" type="System.Diagnostics.TextWriterTraceListener" initializeData="e:\logs\lcars.services.configuration.log" /> 
               <remove name="Default" />  
            </listeners>   
          
        </trace>
     
          <!-- log WCF traffic/messages -->
          <sources>            
              <source name="System.ServiceModel"   
                      switchValue="Information, ActivityTracing"  
                      propagateActivity="true">  
                <listeners>  
                  <add name="lcars_listener" /> 
                  <remove name="Default"/>
                </listeners>  
            </source>  
          </sources>  
        
          <sharedListeners>  
            <add name="lcars_listener"   
              type="System.Diagnostics.XmlWriterTraceListener"   
              initializeData="e:\logs\lcars.services.configuration.svclog">  
            </add>  
        </sharedListeners>   
      </system.diagnostics>

    Monday, December 9, 2019 3:05 PM

All replies

  • Hi,

      

    On my side, when I use the shared listeners to log TraceStatement and WCF trace, it works properly.

    <system.serviceModel>
        <diagnostics>
          <messageLogging logEntireMessage="true" logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="true"></messageLogging>
        </diagnostics>
      </system.serviceModel>
      <system.diagnostics>
        <trace autoflush="true" indentsize="4">
          <listeners>
            <add name="xmllog"/>
          </listeners>
        </trace>
        <sources>
          <source name="System.ServiceModel"
                           switchValue="Information, ActivityTracing"
                           propagateActivity="true">
            <listeners>
              <add name="xmllog"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add name="xmllog" type="System.Diagnostics.XmlWriterTraceListener"  initializeData="mylog.svclog"/>
        </sharedListeners>
      </system.diagnostics>

    Result.
    https://i.stack.imgur.com/zWSEj.png
    Feel free to let me know if there is anything I can help with.
    Best Regards

    Abraham

    Tuesday, December 10, 2019 9:37 AM