9

Just like there is a command to flush IIS7 logs:

netsh http flush logbuffer

I'm wondering is there a similar command to flush WCF trace log on demand.

Charles
  • 50,943
  • 13
  • 104
  • 142
Piotr Owsiak
  • 6,081
  • 8
  • 39
  • 42

2 Answers2

29

Setting the autoflush="true" in your .config file ensures that the trace sources flush to disk after each trace.

The following is a sample configuration file with autoflush="true":

<configuration>
 <system.diagnostics>
  <sources>
   <source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
                 propagateActivity="true">
     <listeners>
      <add name="xml" type="System.Diagnostics.XmlWriterTraceListener"
                      initializeData="e2eTraceTest.xml" />
    </listeners>
   </source>
  </sources>

  <trace autoflush="true" />

 </system.diagnostics>
</configuration>

In addition, if by any chance you are willing to store your WCF trace in a database, you might want to check out this post:

This would allow you to view your WCF trace in real-time, without flushing it.

Community
  • 1
  • 1
Daniel Vassallo
  • 337,827
  • 72
  • 505
  • 443
  • @Piotr: You may also want to consider the `autoflush=true` method, as described in the answer. – Daniel Vassallo Dec 21 '09 at 15:37
  • 2
    That's what I did eventually. However I would rather have buffering that would conserve resources and allowed flushing either on demand and on buffer overflow (and/or low resource usage). I just think that would be beneficial from server's perspective. – Piotr Owsiak Jan 20 '10 at 10:20
  • @Piotr: Yes, I agree with you. – Daniel Vassallo Jan 20 '10 at 10:22
2

One way is to do an IIS reset, but this is only really an option when debugging on a developmnet box.

Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252