【发布时间】:2014-04-23 15:32:54
【问题描述】:
我已在 WCF 服务中启用跟踪。这是 system.diagnostics 部分:
<configuration>
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.ServiceModel" switchValue="All" propagateActivity="true">
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="All">
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xmlTraceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\KryptonTracing\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
这里的 system.serviceModel 部分仅显示诊断:
<diagnostics wmiProviderEnabled="true">
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="3000"
/>
</diagnostics>
当我发布服务时,我在服务器上的 Windows 事件查看器中看到一个信息事件,内容如下:
消息记录已开启。敏感信息可能是 以明文方式登录,即使它是在网络上加密的:对于 例如,消息正文。
当我转到服务器上的 C:\KryptonTracing 文件夹时,没有生成 Traces.svclog。我已经进入 IIS 并查看了此 WCF 服务正在运行的应用程序池标识,并赋予该标识对文件夹的完全控制权.. 仍然没有。无论我做什么,我都无法创建 Traces.svclog。仅供参考,此服务是具有自定义身份验证的 wsHttpBinding (SSL),但这无关紧要。
我试过everything in this post 无济于事。请帮忙。
【问题讨论】:
-
为什么你的
<system.diagnostics>在<configSections>下面?是错字吗?它应该在根标签<configuration>下。 -
抱歉打错了,我已经编辑了帖子。
-
WCF 服务工作正常吗?也许一个请求永远不会到达 WCF 以被记录。我看不出你的配置有什么问题。
-
是的,该服务正在运行。我可以使用客户端来证明请求正在通过并且数据库正在更新。我还可以查看 IIS 日志并查看正在命中的服务。该服务具有 wsHttpBinding 和自定义身份验证,但这应该不是问题。
-
当您为 System.ServiceModel.MessageLogging 和 System.ServiceModel 设置单独的日志文件时,它是否有效?尝试为 C:\KryptonTracing 文件夹上的每个人设置权限。只是为了确定:)
标签: wcf trace system.diagnostics