首页 文章

Azure ServiceFabric示例未记录到ETW

提问于
浏览
9

我正在运行ServiceFabric的第一个示例(预览版本1.4.87):https://azure.microsoft.com/en-us/documentation/articles/service-fabric-create-your-first-application-in-visual-studio/,以创建有状态服务,虽然示例运行正常,但我没有在诊断窗口中看到ETW输出日志信息 .

对日志的调用是 ServiceEventSource.Current.ServiceMessage(...) ,但是当此方法(在ServiceEventSource.cs中实现)运行时,对 this.IsEnabled() 的调用返回false,因此不会写入任何诊断信息 . 如果我在调试中绕过 IsEnabled() 调用,仍然没有任何内容写入诊断窗口,该窗口只包含应用程序的启动消息 .

诊断程序中配置的提供程序是默认提供程序:

Microsoft-ServiceFabric-Actors
Microsoft-ServiceFabric-Services
cbd93bc2-71e5-4566-b3a7-595d8eeca6e8:5:0x4000000000000000

我已将Microsoft-ServiceFabric添加到此列表中,但这只会让我获得更多日志记录,但仍然不是我的输出消息 .

我还运行了PerfView,然后查看可用的提供程序,上面的前两个不存在:Microsoft-ServiceFabric-Actors和Microsoft-ServiceFabric-Services .

任何的想法?这似乎是纯ETW问题或设置中的某种ServiceFabric错误,诊断窗口中的提供程序规范可能不正确 .

我正在运行Win10,VS2015 Enterprise x64 .

[Edit] Program.cs中的调用 ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(MyStatefulService).Name) 也没有写出任何内容 . 我唯一的消息是:

Service Created: Service fabric:/MyApplication/MyStatefulService partition 9505f2b3-dee5-4ea7-96b7-c861407b5283 of ServiceType MyStatefulServiceType created in Application fabric:/MyApplication ApplicationType MyApplicationType.

RunAsync has been invoked for a stateful service replica.  Application Type Name: MyApplicationType, Application Name: fabric:/MyApplication, Service Type Name: MyStatefulServiceType, Service Name: fabric:/MyApplication/MyStatefulService, Partition Id: 9505f2b3-dee5-4ea7-96b7-c861407b5283, Replica Id: 130996049833056865",

The Resource Balancer completed the Creation phase and consequently issued the action -- Add on Service -- fabric:/MyApplication/MyStatefulService Partition -- 9505f2b3-dee5-4ea7-96b7-c861407b5283 with (if relevant) SourceNode -- N/A and TargetNode -- Node.2.

(重复其他节点)

2 回答

  • 0

    要查看EventSource中的事件,您需要将其名称添加到“诊断”窗口中的提供程序列表中 . 查看ServiceEventSource定义,它将具有[EventSource(Name =“xxx”)]属性 . 这是您需要在提供者列表中的名称('xxx') .

    启动诊断Windows时,Visual Studio通常会自动检测解决方案中的EventSources;不知道为什么它不适合你,但手动添加它应该可以解决问题 .

  • 14

    在重新组织我的解决方案后,我遇到了这个问题 . 我将服务项目移动到解决方案文件夹中 . 这就是诊断事件查看器停止从我的服务中获取消息的时间 .

    将项目移回解决方案的根级别后,Visual Studio会自动将事件源名称添加到ETW提供程序列表中 .

    现在,使用VS 2017和/或Azure Service Fabric SDK 2.5.216.0可以修复此错误 .

相关问题