0

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.

Nicolas Voron
  • 2,916
  • 1
  • 21
  • 35
  • 1
    [Semantic Logging](https://msdn.microsoft.com/en-us/library/dn440729(v=pandp.60).aspx) ? – Old Fox Aug 21 '15 at 10:24
  • Exactly the type of solution I am looking for. Except the fact that I run an universal app (windows 10), and this lib isn't compatible with it (as far as i know). This was still very interesting and describes what i have to do if I want to write my own. :) – Nicolas Voron Aug 21 '15 at 14:20
  • Actually according to [Grigori Melnik](http://blogs.msdn.com/b/agile/archive/2013/04/25/just-released-microsoft-enterprise-library-6.aspx)(he is a Principal Program Manager for Microsoft patterns & practices) this library support `Windows Store apps`.... – Old Fox Aug 21 '15 at 17:18
  • I may have to recompile it myself in this case ; Any Nuget package is available for this configuration. BTW, your link say that it supports windows store apps, not universal ones. – Nicolas Voron Aug 24 '15 at 15:06

1 Answers1

2

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)

Jeffrey Chen
  • 4,650
  • 1
  • 18
  • 22
  • The problem with that is the `StorageFileEventListener` will *always* write to file, one event at a time. I don't want that. I want to write the memory buffer to disk IF something wrong happens, for performance reasons – Nicolas Voron Aug 25 '15 at 07:15
  • Yes, you can declare a bytes array like byte[2048] as a buffer, and write the buffer to file when the buffer is full. – Jeffrey Chen Aug 25 '15 at 07:24