【问题标题】:System Diagnostics Log Creation in WCF Calls not workingWCF 调用中的系统诊断日志创建不起作用
【发布时间】:2016-11-06 21:32:45
【问题描述】:

我正在为我的 WPF 应用程序提供 WCF 服务。我希望监控从客户端应用程序收到的所有呼叫。

我阅读了一篇关于 WCF 跟踪的文章 http://dotnetmentors.com/how-to-enable-wcf-tracing-and-wcf-message-loging.aspx

我在 WCF Web.Config 中使用了相同的代码

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
            switchValue="All"
                propagateActivity="true">
        <listeners>
          <add name="messages"
          type="System.Diagnostics.XmlWriterTraceListener"
          initializeData="d:\logs\messages.svclog" />
        </listeners>
      </source>
    </sources>
    <trace autoflush="false" />
  </system.diagnostics>

但我无法在上述位置创建任何文件d:\logs\messages.svclog

请帮助我如何获取日志文件。

【问题讨论】:

    标签: c# wcf logging wcf-data-services system.diagnostics


    【解决方案1】:

    您需要添加两个部分,即 system.diagnostics 中的源和 system.serviceModal 部分下的消息记录:

    <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging" switchValue="Verbose, ActivityTracing">
            <listeners>
              <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="d:\WcfMessageTrace.svclog" />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>
      <system.serviceModel>
         <diagnostics>
          <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
        </diagnostics>
      </system.serviceModel>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 1970-01-01
      • 2016-09-28
      • 2010-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多