Nicolas Voron
Nicolas Voron

Reputation: 2996

ETW/Eventsource tracing to file (dump)

I use ETW to do tracing in my application. So I create a custom EventSource and EventListener.

Now I want to use this tracing from a client side. For example, I want my app to dump the tracing log to a file when the app get an unhandled exception, so i will be able to know what happened remotely (so i want a trace dump).

Question 1 : Is ETW design for this (dump) or is it just a tracing tool and I have to implement another distinct solution ?

Question 2 : (If Question 1 => ETW can do such things) How can i achieve this ?

EDIT : This is for Windows 10 Universal App.

Upvotes: 0

Views: 1754

Answers (1)

Jeffrey Chen
Jeffrey Chen

Reputation: 4680

You can’t use the Semantic Logging in UWP because it is not compatible with .NET for UWP.

Question 1 : Is ETW design for this (dump) or is it just a tracing tool and I have to implement another distinct solution ?

Event Tracing for Windows (ETW), as its name suggests, it is used for event tracking. You can check the event detail in the Event Viewer. A dump file is a snapshot of an app at the point in time the dump is taken. It shows what process was executing and what modules were loaded. It is not limited to the event tracing. For example, a Kernel Memory Dump contains all the memory in use by the kernel at the time of the crash. Summary: ETW is not designed for dump.

Question 2 : (If Question 1 => ETW can do such things) How can i achieve this ?

If you want to log all of the unhandled exceptions in a file, you can use the ETW to do this. There is a sample shows how to use the ETW (Event Tracing for Windows) namespaces to write application events to a storage file on the application local storage. Although it is for Windows Store Apps, you can still use the source code in UWP project (copy the MetroEventSource.cs and StorageFileEventListener). If you want to send the log message to remote client, you need to implement a event listener like UDPEventListener sending the message to a remote client.

Logging Sample for Windows Store Apps (ETW Logging in WinRT)

Upvotes: 2

Related Questions