Service Fabric Web API项目

时间:2017-05-25 17:47:32

标签: c# azure-service-fabric diagnostics

我正在尝试对我的服务结构web api项目进行一些登录,并且它始终被禁用。在使用任何其他SF项目类型之前,我从未见过这种行为。

[NonEvent]
    public void ServiceMessage(ServiceContext serviceContext, string message, params object[] args)
    {
        if (IsEnabled())
        {
            string finalMessage = string.Format(message, args);

            ServiceMessage(
                serviceContext.ServiceName.ToString(),
                serviceContext.ServiceTypeName,
                GetReplicaOrInstanceId(serviceContext),
                serviceContext.PartitionId,
                serviceContext.CodePackageActivationContext.ApplicationName,
                serviceContext.CodePackageActivationContext.ApplicationTypeName,
                serviceContext.NodeContext.NodeName,
                finalMessage);
        }
    }

IsEnabled始终返回false。您是否需要为Web api项目执行特殊设置?这也是.net核心。不确定这是否会影响它。

1 个答案:

答案 0 :(得分:1)

它不依赖于SF项目类型。找出EventSource的名称:

[EventSource(Name = "MyCompany-SFApp-Stateful1")]
internal sealed class ServiceEventSource : EventSource

在这种情况下,它是 MyCompany-SFApp-Stateful1 。然后,您需要在诊断事件选项卡中添加此名称作为ETW提供程序(查看 - 其他Windows - 诊断事件

enter image description here