views:

554

answers:

3

I enabled message tracing on a WCF service. it traces a couple of messages and then it stops, when I try to open the trace in TraceViwer it gives me an error on the last message that got logged, or doesn't even open the file duo to different error everytime.

I can't even delete the corrupt file unless i run a resetiis since the file is being used!

here is my trace config.

<system.diagnostics>
     <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
       <listeners>
        <add type="System.Diagnostics.DefaultTraceListener" name="Default">
         <filter type="" />
        </add>
        <add name="ServiceModelMessageLoggingListener">
         <filter type="" />
        </add>
       </listeners>
      </source>
     </sources>
     <sharedListeners>
      <add initializeData="C:\Logs\Web_messages.svclog"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
       <filter type="" />
      </add>
     </sharedListeners>
    </system.diagnostics>

<system.serviceModel>
 <diagnostics>
  <messageLogging logEntireMessage="true" logMalformedMessages="true"
    logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
 </diagnostics>
</system.serviceModel>
A: 

Is the service still running? Then the problem may simply be that the file has not been flushed yet.

John Saunders
+6  A: 

Per John's answer, you can use Trace.AutoFlush to flush the file after every write. Something along the lines of this example ...

<system.diagnostics>
   <sources>
       <source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
          <listeners>
              <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="C:\logs\UserTraces.svclog" />
          </listeners>
       </source>
   </sources>
   <trace autoflush="true" /> 
</system.diagnostics>
JP Alioto
Hah! I didn't know about that!
John Saunders
John, that makes my day ... maybe my week! :)
JP Alioto
sometimes i wonder what i used to do without this site.
Keivan
Glad to help, Kay!
JP Alioto
A: 

What happens when AutoFlush is set to True and it's not flushing? I have this situation now. I have the proper configuration set up, but I don't see WCF call results right away in the file. In fact, I saw the results the next day after I had logged back into my machine. What's up with this? I've tried to stop the web services in IIS and restart, shut down the IIS administrator and there's still some lock on that log file and I can't even delete it now.

Bruce
that sounds weird. I haven't had any issues since i enabled autoflush.
Keivan