ETW/Eventsource tracing to file (dump)

冷暖自知 提交于 2019-12-11 19:54:43

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/32113085/etw-eventsource-tracing-to-file-dump

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!