Semantic Logging IsEnabled si always false?

与世无争的帅哥 提交于 2019-12-23 00:52:27

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/37561974/semantic-logging-isenabled-si-always-false

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!