Question

Im using Microsoft Service Configuration Editor to setup diagnostics(WCF logging) and I can´t find any way to set the max file size?

I have found the MaxSizeOfMessageToLog but that do nothing about the file size?

Edit 1: According to this : http://msdn.microsoft.com/en-us/library/aa395205.aspx There should be a maxFileSizeKB at the sharedListeners level but when hitting space in the add tag I do not get the possibility to type maxFileSizeKB?

Edit 2: When adding the maxFileSizeKB the serivce will not start anymore, instead I will get the following excetion :

'maxFileSizeKB' is not a valid configuration attribute for type 'System.Diagnostics.XmlWriterTraceListener'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Configuration.ConfigurationErrorsException: 'maxFileSizeKB' is not a valid configuration attribute for type 'System.Diagnostics.XmlWriterTraceListener'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Edit 3 :

I had to download the Circular TraceListener sample and include it in my project, there is no built in fileSize limiter.

My config looks like this now :

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
        <listeners>
          <add name="ServiceModelMessageLoggingListener"/>
        </listeners>
      </source>
      <source name="System.ServiceModel" switchValue="Warning,ActivityTracing"
        propagateActivity="false">
        <listeners>
          <add name="ServiceModelTraceListener"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\My\MyRelease 0.31\Host\My.Host.Dev\web_messages.svclog"
        type="Microsoft.Samples.ServiceModel.CircularTraceListener,CircularTraceListener"
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp" maxFileSizeKB="1024">
        <filter type="" />
      </add>
      <add initializeData="C:\My\MyRelease 0.31\Host\My.Host.Dev\web_tracelog.svclog"
        type="Microsoft.Samples.ServiceModel.CircularTraceListener,CircularTraceListener"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp" maxFileSizeKB="1024">
        <filter type="" />
      </add>
    </sharedListeners>

This is limiting the message log file but not the trace log file?

Was it helpful?

Solution

It's because the link your gave use a custom trace listener ("Microsoft.ServiceModel.Samples.CircularTraceListener"), which have a "maxFileSizeKB" property.

There is no built-in functionnality to limit/roll svclog files, so you really need to use a custom trace listener. You can use the sample used in your link (read at the end of the article how to download the code). Or here is another one that can be usefull.

OTHER TIPS

Just want to add to @Fabske answer that inorder for this to work

1) Download WCF samples: http://go.microsoft.com/fwlink/?LinkId=150780

2) Open :\WF_WCF_Samples\WCF\Basic\Management\CircularTracing

3) Build the solution and grab the CircularTraceListener.dll

4) Add that dll to your project references

5) Update your configuration as shown http://msdn.microsoft.com/en-us/library/aa395205(v=vs.100).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top