How to turn on WCF tracing?

后端 未结 4 1048
感动是毒
感动是毒 2020-11-21 23:36

Update:

I have been trying to turn on WCF tracing, but still no success... Below is my lastest update.

Do I need a permission to write to th

相关标签:
4条回答
  • 2020-11-22 00:18

    Instead of you manual adding the tracing enabling bit into web.config you can also try using the WCF configuration editor which comes with VS SDK to enable tracing

    https://stackoverflow.com/a/16715631/2218571

    0 讨论(0)
  • 2020-11-22 00:22

    In your web.config (on the server) add

    <system.diagnostics>
     <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
       <listeners>
        <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\logs\Traces.svclog"/>
       </listeners>
      </source>
     </sources>
    </system.diagnostics>
    
    0 讨论(0)
  • 2020-11-22 00:26

    Go to your Microsoft SDKs directory. A path like this:

    C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools
    

    Open the WCF Configuration Editor (Microsoft Service Configuration Editor) from that directory:

    SvcConfigEditor.exe
    

    (another option to open this tool is by navigating in Visual Studio 2017 to "Tools" > "WCF Service Configuration Editor")

    Open your .config file or create a new one using the editor and navigate to Diagnostics.

    There you can click the "Enable MessageLogging".

    enable messagelogging

    More info: https://msdn.microsoft.com/en-us/library/ms732009(v=vs.110).aspx

    With the trace viewer from the same directory you can open the trace log files:

    SvcTraceViewer.exe
    

    You can also enable tracing using WMI. More info: https://msdn.microsoft.com/en-us/library/ms730064(v=vs.110).aspx

    0 讨论(0)
  • 2020-11-22 00:33

    The following configuration taken from MSDN can be applied to enable tracing on your WCF service.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>
    

    To view the log file, you can use "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\SvcTraceViewer.exe".

    If "SvcTraceViewer.exe" is not on your system, you can download it from the "Microsoft Windows SDK for Windows 7 and .NET Framework 4" package here:

    Windows SDK Download

    You don't have to install the entire thing, just the ".NET Development / Tools" part.

    When/if it bombs out during installation with a non-sensical error, Petopas' answer to Windows 7 SDK Installation Failure solved my issue.

    0 讨论(0)
提交回复
热议问题