EventSource .net 4.0 GenerateManifest [英] EventSource .net 4.0 GenerateManifest

查看:110
本文介绍了EventSource .net 4.0 GenerateManifest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在.net 4.0中使用ETW。

I've been trying to work with ETW in .net 4.0.

我已经开始使用Microsoft EventSource Library 1.0.4-beta( https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.EventSource

I have started using Microsoft EventSource Library 1.0.4-beta (https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.EventSource)

这里是我写的用于为应用程序生成事件的代码。

Here is the code i written for generating events for my application.

[EventSource(Name = "Samples-EventSourceDemos-EventSourceLogger")]
public sealed class EventSourceLogger : EventSource
{
    public static EventSourceLogger Log = new EventSourceLogger();

    public static string GetManifest()
    {
        return GenerateManifest(typeof(EventSourceLogger), null);
    }

    [Event(200, Level = Microsoft.Diagnostics.Tracing.EventLevel.Informational, Task = EventTask.None, Version = 1,
        Opcode = EventOpcode.Info, Keywords = EventKeywords.None, Channel = EventChannel.Admin,
        Message = "Test Message")]
    public void LogEtwInfoEventMessage(string jsonArgs)
    {
        if (!this.IsEnabled()) return;

        this.WriteEvent(200, jsonArgs);
    }

    [Event(400, Level = Microsoft.Diagnostics.Tracing.EventLevel.Error, Task = EventTask.None, Version = 1,
        Opcode = EventOpcode.Info, Keywords = EventKeywords.None, Channel = EventChannel.Admin, Message = "Test Message")]
    public void LogEtwErrorEventMessage(string jsonArgs)
    {
        if (!this.IsEnabled()) return;

        this.WriteEvent(400, jsonArgs);
    }

    [Event(500, Level = Microsoft.Diagnostics.Tracing.EventLevel.Warning, Task = EventTask.None, Version = 1,
       Opcode = EventOpcode.Info, Keywords = EventKeywords.None, Channel = EventChannel.Admin, Message = "Test Message")]
    public void LogEtwWarningEventMessage(string jsonArgs)
    {
        if (!this.IsEnabled()) return;

        this.WriteEvent(500, jsonArgs);
    }
}

我无法从监听器生成清单。下面的代码

I am not able to generate manifest from listener. Code Below

var manifestXml = EventSourceLogger.GetManifest();

当我尝试调用此函数时,我收到NullReferenceException,请建议我缺少任何东西。可以使用此版本将EventMessage推送到EventViewer。

When I try to call this I get NullReferenceException, Please suggest I am missing any thing. Is it possible to push EventMessage to EventViewer using this version.

作为此NuGet软件包的一部分,我具有eventRegister,Install Bat,Microsoft.Diagnostics.Tracing.EventSource.targets 。我不太确定这些方法如何有助于清单生成。

As Part of this NuGet Package, I have eventRegister, Install Bat, Microsoft.Diagnostics.Tracing.EventSource.targets. I am not really sure how these would help in manifest generate.

如果有人对此有任何想法(或),请帮助。

If any one have any ideas (or) worked on this, Please help.

谢谢。

推荐答案

我能够找到解决方法。现在,我可以注册事件并将其发布到eventviewer。

I was able find a solution for this. Now i am able to register and publish the events to the eventviewer.

http://naveensrinivasan.com/2010/03/17/using-clr-4 -0-event-tracking-for-windows-etw-along-with-application-etw /

谢谢。

这篇关于EventSource .net 4.0 GenerateManifest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆