我正在对 WCF 服务使用 Application Insights 跟踪,但我看不到调用了哪个特定操作,更重要的是,我看不到作为 WCF 操作的一部分执行了哪些数据库操作/http 调用。
我只看到使用 POST 调用了特定的 WCF 服务“.svc
”例如,单击事务,我看不到执行的数据库调用(在 WCF 操作内部执行):
对于其他类似的 Web Api 应用程序,我可以正确地看到数据库调用/http 调用。
WCF 服务是否需要一些特殊配置才能更容易被 Application Insights 发现?
我使用 nuget 包管理器添加了 Application Insights,就像我为其他 Web API 应用程序所做的那样,它可以正常工作。
据我所知,您可以在wcf服务跟踪中使用消息日志记录。
WCF 使用 System.Diagnostics 命名空间中定义的跟踪机制。跟踪使用者为他们想要检索信息的跟踪源创建跟踪侦听器,如下所示:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="All">
<listeners>
<add name="xmlTraceListener"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="All">
<listeners>
<add name="xmlTraceListener"/>
<add name="textBoxListener"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xmlTraceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="ClientLogBasic.svclog"/>
<add name="textBoxListener" type="WinTransmitterClient.MyTraceListener, WinTransmitterClient" initializeData=""/>
</sharedListeners>
<trace autoflush="true"/>
PS:
<listeners>
标签的名称需要与<sharedListeners>
的名称相同。在 <sharedListeners>
中,类型应包含完整的类名以及命名空间和程序集名称。