Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
/ NLog.Etw Public

NLog Target for Event Tracing for Windows (ETW)

License

Notifications You must be signed in to change notification settings

NLog/NLog.Etw

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

160 Commits
160 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NLog.Etw

Version AppVeyor codecov.io

NLog Target for writing logevents to Event Tracing for Windows (ETW).

Install nuget-package to your project:

dotnet add package NLog.Etw

Example NLog.config file

Example of NLog.config-file that writes to ETW:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <extensions>
        <add assembly="NLog.Etw" />
    </extensions>

    <targets async="true">
        <target type="EtwEventSource"
                name="eetw"
                providerName="MyEventSourceName"
                taskName="${level}"
                layout="${message}"
              />
    </targets>
    
    <rules>
      <logger name="*" minlevel="Trace" writeTo="eetw" />
    </rules>
</nlog>

Example Custome EventSource

Example of providing own custom EventSource for writing events:

[EventSource(Name = "MyEventSourceName")]
public class MyEventSource : EventSource, NLog.Etw.INLogEventSource
{
    /// <inheritdoc/>
    [NonEvent]
    public void Write(EventLevel eventLevel, string layoutMessage, LogEventInfo logEvent)
    {
        // TODO Call own custom logging-method
    }

    /// <inheritdoc/>
    EventSource EventSource { get { return this; } }

    internal readonly static MyEventSource Log = new MyEventSource();
}

var config = new NLog.Config.LoggingConfiguration();
config.AddRuleForAllLevels(new NLog.Etw.NLogEtwExtendedTarget(MyEventSource.Log) { Name = "eetw" });
NLog.LogManager.Configuration = config;

Example with EtwEventCounter Target

Example of NLog.config-file that writes to ETW-EventCounter:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <extensions>
        <add assembly="NLog.Etw" />
    </extensions>

    <targets async="true">
        <target type="EtwEventCounter"
                name="etwCounter"
                providerName="MyEventSourceName"
                counterName="MyEventCounterName"
                metricValue="${event-properties:MyMetricValue:whenEmpty=1}"
              />
    </targets>
    
    <rules>
      <logger name="*" minlevel="Trace" writeTo="etwCounter" />
    </rules>
</nlog>

About

NLog Target for Event Tracing for Windows (ETW)

Topics

Resources

License

Stars

Watchers

Forks

Contributors 11

Morty Proxy This is a proxified and sanitized view of the page, visit original site.