0

I want to generate tracing file in WCF on daily basis because single ".svc" is taking too much space in server. Currently we are using below code to log tracing of WCF service -

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Warning, ActivityTracing" propagateActivity="true">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="E:\ServiceLog\WCF_Tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics> 

I tried below code to log tracing on daily basis, but somehow it doesn't work -

<system.diagnostics>
   <sources>
       <source name="System.ServiceModel" switchValue="Warning, ActivityTracing" >
          <listeners>
              <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="E:\ServiceLog\WCF_Tracelog{0:DD}-{0:MM}-{0:yyyy}.svclog" />
          </listeners>
       </source>
   </sources>
   <trace autoflush="true" /> 
</system.diagnostics>

Please suggest, what is wrong in the above config, or is there any different way of doing it.

Nitendra Jain
  • 489
  • 1
  • 7
  • 24
  • You have to implement your own handler, see this: https://stackoverflow.com/questions/10779812/net-wcf-service-trace-log-with-log-file-management-rolling – Ricardo Pontual Jun 27 '17 at 11:56
  • Look at [this answer](https://stackoverflow.com/questions/156575/what-the-best-rollover-log-file-tracelistener-for-net). It contains various options for rolling files. – Igor Labutin Jun 29 '17 at 08:13

0 Answers0