ServiceEventSource is disabled in Service Fabric Web API

I am trying to do some writing in my api service web project and is always disabled. I have never seen this behavior with any other type of SF project.

[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 always returns false. Is there any special setup that needs to be done for Web api projects? This is .net too. Not sure if this is happening.

+3


source to share


1 answer


This does not depend on the type of SF project. Find out your name EventSource

:

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

      



In this case, it is MyCompany-SFApp-Stateful1 . Then you need to add this name as ETW provider on the Diagnostic Events tab (View - Other Windows - Diagnostic Events)

enter image description here

+1


source







All Articles