Semantic Logging IsEnabled si always false?

2019-05-26 19:29发布

I'm using SLAB out-of-process to log ETW events in my applications.

Today I have a problem within WCF services hosted Under WcfTestClient.exe

When I put breakpoint into WriteEvent methods of my EventSource inherited class, IsEnabled() return false !!! So no event is written to my console log out-of-process :(

When starting my ConsoleEventSink, I can see my eventSource registered with a LogAlways level and None for MatchAnyKeyword property

Any idea to check what is wrong for this problem ?

Thanks in advance

标签: c# .net slab
2条回答
三岁会撩人
2楼-- · 2019-05-26 20:11

You probably have an error in your EventSource class.

You can analyze your EventSource to see whether it is correctly defined. See https://dzimchuk.net/post/troubleshooting-slab-out-of-process-logging

There's a Nuget package for it: https://www.nuget.org/packages/EnterpriseLibrary.SemanticLogging.EventSourceAnalyzer/

Try creating a unit test for it and inspect the result

[TestClass]
public class EventSourceTests
{
    [TestMethod]
    public void MyEventSourceShouldBeValid()
    {
        var analyzer = new EventSourceAnalyzer();

        analyzer.Inspect(MyEventSource.Log);
    }
}

EDIT

A (non-official) port to .Net Core is available as well, see this package.

查看更多
甜甜的少女心
3楼-- · 2019-05-26 20:15

EventSource and etw loggers are filtered based on provider guid, event level, and event keyword. I am not familiar with the consoleeventsink, but you'll only get events if you've specifically told the sink to pay attention to your specific provider, usually by giving it the provider's guid. There are literally thousands (maybe tens of thousands) of etw providers running on your system, and you can't just filter on level and keyword - you have to filter on guid as well.

Some etw consumers support providing the provider name instead of the guid, in which case they generate the guid by hashing the name. That often works well with EventSource because that's also the way that EventSource generates its guide as well.

查看更多
登录 后发表回答