none
How to rotate WCF log when maxMessagesToLog is reached? RRS feed

  • Question

  • I have a WCF service and want to enable logging. As described in Microsoft's documentation Configuring Message Logging, I put in the Web.config the following:
    <system.diagnostics>  
      <sources>  
        <source name="System.ServiceModel.MessageLogging">  
          <listeners>  
             <add name="messages"  
                  type="System.Diagnostics.XmlWriterTraceListener"  
                  initializeData="c:\logs\messages.svclog" />  
            </listeners>  
        </source>  
      </sources>  
    </system.diagnostics>  
      
    <system.serviceModel>  
      <diagnostics>  
        <messageLogging   
             logEntireMessage="true"   
             logMalformedMessages="false"  
             logMessagesAtServiceLevel="true"   
             logMessagesAtTransportLevel="false"  
             maxMessagesToLog="3000"  
             maxSizeOfMessageToLog="2000"/>  
      </diagnostics>  
    </system.serviceModel>  
    How can I rotate the log, for example write to messages1.svclog, then messages2.svclog, etc. when the number of messages in the last log has reached maxMessagesToLog=3000?

    I read the article A Rolling XmlWriterTraceListener, but this rotates the log file when a certain file size has been reached. However, when the number of messages reaches maxMessagesToLog, WCF will stop logging.
    Thursday, June 13, 2019 7:37 AM

All replies

  • Hi Pappasa,
    As far as I know, the ability to customize logs with such precision should not be possible. 
    Messages and activities in the log should be inseparable. 
    This may have something to do with performance. 
    In addition, we can filter in the log trace viewer if necessary.
    Best Regards
    Abraham
    Friday, June 14, 2019 8:05 AM
    Moderator