如何在EventSource中记录多个字段

时间:2018-06-12 22:14:20

标签: etw-eventsource

我正在使用EventSource来记录事件。我需要为一个事件记录30个字段。如果我将所有30个字段逐个作为字符串传递,它就可以工作,如下所示。我能够记录这些事件。但是当我尝试将string[]传递给WriteEvent()时。 isEnabled()返回false。 是否有更好的方法将多个字段传递到WriteEvent()方法?

以下是我的活动提供商的源代码。

sealed class NemoTraceLoggingProvider : EventSource
    {
        public static NemoTraceLoggingProvider Log = new NemoTraceLoggingProvider();

        [Event(1, Version = 12)]
        public void SendTraceLoggingEvent(string Host, string Machine, string NemoVersion, string TraceId, string Operation, string HttpResult, string CallDuration, string Segment, string InputCells,
            string InputTargetCells, string InputTargetContext, string IdentifyEntitySurfaceFormsIterations, string IdentifyEntitySurfaceFormsMaxDuration,
            string IdentifyEntitySurfaceFormsInstancesCount, string ResolveMethod2Iterations, string ResolveMethod2MaxDuration,
            string ResolveMethod2InstancesCount, string ResolveMethod3Iterations, string ResolveMethod3MaxDuration, string ResolveMethod3InstancesCount,
            string ExtractPatternIterations, string ExtractPatternMaxDuration, string ExtractPatternInstancesCount, string NormalizeTextIterations,
            string NormalizeTextMaxDuration, string NormalizeTextInstancesCount, string MaxDocumentTopics, string MaxSurfaceTopics, string MaxSurfaceWords,
            string MaxTopicWords)
        {
            if (IsEnabled())
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("TraceLogging: event is send out");
                Console.ResetColor();
                WriteEvent(1, Host, Machine, NemoVersion, TraceId, Operation, HttpResult, CallDuration, Segment, InputCells,
                            InputTargetCells, InputTargetContext, IdentifyEntitySurfaceFormsIterations, IdentifyEntitySurfaceFormsMaxDuration,
                            IdentifyEntitySurfaceFormsInstancesCount, ResolveMethod2Iterations, ResolveMethod2MaxDuration,
                            ResolveMethod2InstancesCount, ResolveMethod3Iterations, ResolveMethod3MaxDuration, ResolveMethod3InstancesCount,
                            ExtractPatternIterations, ExtractPatternMaxDuration, ExtractPatternInstancesCount, NormalizeTextIterations,
                            NormalizeTextMaxDuration, NormalizeTextInstancesCount, MaxDocumentTopics, MaxSurfaceTopics, MaxSurfaceWords,
                            MaxTopicWords);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Not Enabled!!!");
                Console.ResetColor();
            }
        }
    }
}

谢谢!

0 个答案:

没有答案