DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Using ETW Tracing on Windows 10 IoT Core

Using ETW Tracing on Windows 10 IoT Core

Getting ETW tracing set up on Windows 10 IoT Core is not intuitive. There are surprises when creating an event source, registering the provider, and saving the results.

Gunnar Peipman user avatar by
Gunnar Peipman
·
Jan. 30, 17 · Tutorial
Like (0)
Save
Tweet
Share
4.24K Views

Join the DZone community and get the full member experience.

Join For Free

here is how to make a custom event source for etw (event tracing for windows) work on windows 10 iot core. it’s not as simple as developers of business solutions are used to microsoft's tooling to be, but it’s also not too complex or time-consuming to do. this article introduces a simple logging class and steps to make it work on windows 10 iot core.

the source code here comes from my temperaturestation iot solution on github.

creating an etw event source

here is the class i’m using for logging to the etw trace on a raspberrypi. i’m using a custom ilogger interface to support more, different loggers.

[eventsource(name = “temperaturestationeventsource”)]
internal sealed class temperaturestationeventsource : eventsource, ilogger
{
    [event(1, level = eventlevel.verbose, channel = eventchannel.debug)]
    public void debug(string message)
    {
        writeevent(1, message);
    }
    [event(2, level = eventlevel.informational, channel = eventchannel.debug)]
    public void info(string message)
    {
        writeevent(2, message);
    }

    [event(3, level = eventlevel.warning, channel = eventchannel.debug)]
    public void warn(string message)
    {
        writeevent(3, message);
    }

    [event(4, level = eventlevel.error, channel = eventchannel.debug)]
    public void error(string message)
    {
        writeevent(4, message);
    }

    [event(5, level = eventlevel.critical, channel = eventchannel.debug)]
    public void critical(string message)
    {
        writeevent(5, message);
    }
}


i wanted the trace logs from my iot background service to be shown in the web interface of my raspberrypi. but no matter what i tried, my traces just didn’t get there. yes, i also tried the custom providers stuff by guid, but still no luck. so i started looking for a way how to get my event source registered.

windows 10 iot: registered etw providers

registering the etw trace provider

after some searching on the web, i found a working solution. there’s some tricking and hacking needed to get the new event source registered. here are the steps.

  1. add a reference to the nuget package microsoft.diagnostics.tracing.eventsource.
  2. build the application, get the error, and take the failed command (with copy and paste) to a text editor. remove all the other stuff besides the command that was run. it should look similar to this:
  3. “c:\users\xxx\.nuget\packages\microsoft.diagnostics.tracing.eventregister\1.1.28\build\eventregister.exe” -dumpregdlls @”d:\projects\temperaturestation\temperaturestation.iot.service\bin\arm\debug\
    
    temperaturestation.iot.service.eventregister.rsp” “d:\projects\temperaturestation\temperaturestation.iot.service\
    
    bin\arm\debug\temperaturestation.iot.service.winmdobj”


  4. remove the reference to microsoft.diagnostics.tracing.eventsource. your application builds now, but the package is still available on your machine.
  5. change the file name in the previously copied command from winmdobj to winmd ( important! ):
  6. “c:\users\xxx\.nuget\packages\microsoft.diagnostics.tracing.eventregister\1.1.28\build\eventregister.exe” -dumpregdlls @”d:\projects\temperaturestation\temperaturestation.iot.service\bin\arm\debug\
    
    temperaturestation.iot.service.eventregister.rsp” “d:\projects\temperaturestation\temperaturestation.iot.service\
    
    bin\arm\debug\temperaturestation.iot.service.winmd”
  7. take the command with copy-paste and run it on a command prompt.
  8. check if two new files were created in the bin folder of application. the names should be similar to ones i got with my temperaturestation iot service: temperaturestation.iot.service.temperaturestationeventsource.etwmanifest.dll
    temperaturestation.iot.service.temperaturestationeventsource.etwmanifest.man
  9. copy the files to some folder on the raspberry.
  10. log into the raspberry using powershell. move to the folder where you put those two files and run the following command (replace the placeholders with the real file names, of course):
  11. wevtutil.exe im <etwmanifestmanfile> /rf:”<etwmanifestdllfile>” /mf:”<etwmanifestdllfile>” 


  12. check your browser to see if your provider is listed in the etw providers list.
  13. if it’s not there, then restart raspberry.

supposing everything went fine the new event source should appear in providers dropdown on etw traces page of raspberrypi. but there’s one little gotcha.

saving etw traces for later use

the previous solution works only when etw traces are monitored through the browser, but the traces are not saved for later use. if trace logs must be saved, then log into the raspberry pi using powershell and run the following command (change myewtprovider to the provider name you are using): echo y | wevtutil.exe sl myewtprovider/debug /e:true

to get archived trace logs, use the following command on the raspberry pi when logged in using powershell: wevtutil.exe qe myewtprovider/debug

saved logs should also be available on the etw traces page of the raspberry pi.

wrapping up

etw logging is not easy to understand and implement when doing it the first time. manual registering of etw event sources was a little bit of a surprise to me. also, the fact that there is incompatible component that fails during the build was surprising. but in the end, i was able to get things working the way i needed. i hope it saves time for those who need etw traces on a raspberry pi.

IoT

Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Kubernetes vs Docker: Differences Explained
  • Better Performance and Security by Monitoring Logs, Metrics, and More
  • How to Create a Real-Time Scalable Streaming App Using Apache NiFi, Apache Pulsar, and Apache Flink SQL
  • Top 10 Secure Coding Practices Every Developer Should Know

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: