wcf 尝试设置跟踪以进行调试,而不是写入日志文件 [英] wcf trying to set up tracing to debug, not writing to log file

查看:31
本文介绍了wcf 尝试设置跟踪以进行调试,而不是写入日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 web.config,在 IIS7 上的应用程序中运行 WCF 服务,但没有将任何内容写入指定文件.已授予所有人对该文件的权限.

here's my web.config, running a WCF service in an application on IIS7, but nothing is being written to the specified file. permission on the file has been granted for everyone.

<system.diagnostics>
  <sources>
   <source name="System.ServiceModel" switchValue="Information, ActivityTracing,     error, warning, critical" propagateActivity="true">
    <listeners>
     <add name="traceListener"
  type="System.Diagnostics.TextWriterTraceListener"
  initializeData="c:\log\tracestext.log" />

    </listeners>
  </source>
  </sources>
 </system.diagnostics>

我可以添加服务引用就好了.
然后我尝试从 Windows 应用程序调用该服务,几分钟后,在运行 Windows 应用程序的机器上出现错误客户端无法在配置的超时 (00:00:00) 内完成安全协商."当前协商段为 1 (00:00:00)."

I can add a service reference just fine.
I then try to call the service from a windows app and, after a few minutes, get an error on the machine running the windows app "Client is unable to finish the security negotiation within the configured timeout (00:00:00). The current negotiation leg is 1 (00:00:00)."

但绝对没有任何内容写入配置中指定的跟踪日志文件.

but absolutely nothing is written to the trace log file specified in config.

我还需要做些什么来启用跟踪吗?感谢您的帮助

Is there something else I need to do to enable tracing? thanks for your help

来源"部分现在与此处推荐的部分匹配:http://msdn.microsoft.com/en-us/library/aa702726.aspx

"sources" section now matches the section recommended here: http://msdn.microsoft.com/en-us/library/aa702726.aspx

我已将diagnostics.messagelogging"部分添加到system.servicemodel"

I've added the "diagnostics . messagelogging" section to "system.servicemodel"

并且事件查看器显示:消息记录已打开.敏感信息可能会以明文形式记录,即使是在网络上加密的:例如,消息正文.进程名称:w3wp进程 ID:1784"

and the event viewer shows: "Message Logging has been turned on. Sensitive information may be logged in the clear, even if it was encrypted on the wire: for example, message bodies. Process Name: w3wp Process ID: 1784 "

但是日志文件还是空的

推荐答案

是的 - 您只定义了一些 .NET 跟踪源和侦听器 - 但您还没有指示 WCF 实际执行跟踪!

Yes - you've only just defined some .NET tracing source and listeners - but you haven't instructed WCF yet to actually do the tracing!

您还需要:

<system.serviceModel>
    <diagnostics>
        <messageLogging 
            logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="false"
            logMalformedMessages="true" logEntireMessage="true"
            maxSizeOfMessageToLog="65535000" maxMessagesToLog="500" />
    </diagnostics>
</system.serviceModel>

这两部分的配置结合起来就可以了!

These two sections of config combined should do it!

为了立即将您的消息写回日志文件,您可能需要在 部分添加一个设置:

In order to get your messages written back to the log file right away, you might want to add a setting to your <system.diagnostics> section:

<system.diagnostics>
    ... everything you already have....

    <trace autoflush="true" />
</system.diagnostics>

这篇关于wcf 尝试设置跟踪以进行调试,而不是写入日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆