Raghu
Raghu

Reputation: 3069

Setting ETW event level in service fabric tracing

When you create a service fabric application project using visual studio, you get an implementation of EventSource (called ServiceEventSource). For example, here is one of the method implementation:

    private const int ServiceRequestStopEventId = 6;
    [Event(ServiceRequestStopEventId, Level = EventLevel.Informational, Message = "Service request '{0}' finished", Keywords = Keywords.Requests)]
    public void ServiceRequestStop(string requestTypeName)
    {
        WriteEvent(ServiceRequestStopEventId, requestTypeName);
    }

As you can see, this method has Event attribute which has Level argument set.

  1. Where would I set that Level argument value?
  2. I am thinking that setting this Level's argument value will show how much output gets generated. Am I correct?
  3. Can I modify this Level argument value dynamically at run time and at will?

Upvotes: 1

Views: 1711

Answers (2)

cassandrad
cassandrad

Reputation: 3526

  1. You can set Level only in the Event attribute.
  2. The amount of output getting generated depends on consumers of logs. If there are no consumers or listeners, event will not be generated at any level. We can say that level depends on amount of output, but only if there are consumers of such event.
  3. No, you can't modify the level dynamically. To do this, you could have two methods with the same signature and different levels.

You can find all the interesting information about ETW and its configuration here.

Upvotes: 2

LoekD
LoekD

Reputation: 11470

The code just indicates information about the ETW events it generates. Setting the level indicates in which category the event will be put. It doesn't configure whether the event is output. The logging tool determines whether it's logged or not. And you can usually change that level in the logging tool at run time.

Some useful links:

  1. Configure WAD: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-diagnostics-how-to-setup-wad/

  2. Use Elastic Search https://azure.microsoft.com/en-us/documentation/articles/service-fabric-diagnostic-how-to-use-elasticsearch/

  3. Use OMS to analyse the events. https://azure.microsoft.com/en-us/documentation/articles/log-analytics-service-fabric/

  4. Use Service Profiler (Actors) https://www.azureserviceprofiler.com/

Upvotes: 1

Related Questions