WCF Trace and Message Logging don't write log files on service host (server) side

10,730

I wrote this up a month or so ago after I got trace logging working. See if it helps you. Nothing jumps out at me in your config that looks incorrect. However, maybe starting again with my config will help shed some light on the situation.

Share:
10,730
Erikest
Author by

Erikest

Humble coder travelling about, working from wherever

Updated on June 05, 2022

Comments

  • Erikest
    Erikest almost 2 years

    I've got some kind of error with my WCF services.

    I need to determine what's going on, so I've attempted to enable service trace logging.

    I followed the prescribed guidelines and used the wcf configuration editor to setup tracing and message logging in both my client and server.

    Tracing works fine on the client side, but the messages are of limited use in this case since they simply indicate that the real failure has been on the server and I should check the server logs:

    An error occurred while receiving the HTTP response to http://localhost:24162/MembershipService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

    I'm running in debug mode, so the server in this case is the asp.net development server running on port 24162.

    My diagnostics section of the service host's web.config:

     <system.diagnostics>
    <sources>
      <source propagateActivity="true" name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose,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_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
      <add initializeData="C:\Logs\web_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
    <trace autoflush="true" />
    

    and the system.servicemodel portion

    <system.serviceModel>
            <diagnostics>
          <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
            logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
          <endToEndTracing propagateActivity="true" activityTracing="true"
            messageFlowTracing="true" />
        </diagnostics>
    </system.serviceModel>
    

    The directory "C:\Logs" does exist and I've given 'Everyone' full control. I've also verified that the TRACE constant is defined just to be sure.

    As you can see, I'm trying to capture anything and everything that the trace/message logging has to offer. Anything at all. But alas, I'm getting nothing, nada, zilch.

    After reviewing the extant questions on this site and doing a fair amount of googling, following some suggestions (making sure the folder exists, verifying that the user has appropriate permissions on the folder), I feel no closer to understanding why my tracing writes no files. Any suggestions on how to troubleshoot trace logging? Is there any information logged somewhere else that would indicate why tracing is not working?

    for reference and future readers -

    I went here for service trace logging configuration instructions. I went here and here to try and troubleshoot the log files not being written.