ETW Provider Registration Issues

I am working on a UWP application for Windows 10 IoT, and I want to configure ETW tracing so that I can remotely view the log using the integrated web interface:

ETW List

I believe that I created the necessary types, however I can not see my provider in any of the lists shown in the IoT ETW section:

ETW Options

Implementation of EventListener My :

sealed class StorageFileEventListener : EventListener { /// <summary> /// Storage file to be used to write logs /// </summary> private StorageFile _mStorageFile = null; /// <summary> /// Name of the current event listener /// </summary> private readonly string _mName; public StorageFileEventListener(string name) { _mName = name; Debug.WriteLine("StorageFileEventListener for {0} has name {1}", GetHashCode(), name); AssignLocalFile(); } private async void AssignLocalFile() { _mStorageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(_mName.Replace(" ", "_") + ".log", CreationCollisionOption.OpenIfExists); } private async void WriteToFile(IEnumerable<string> lines) { // TODO: } protected override void OnEventWritten(EventWrittenEventArgs eventData) { // TODO: } protected override void OnEventSourceCreated(EventSource eventSource) { // TODO: } } 

Implementation of My EventSource :

 internal sealed class Logger : EventSource { public static Logger Log = new Logger(); [Event(1, Level = EventLevel.Verbose)] public void Debug(string message, Exception exception) { var exceptionMessage = GenerateExceptionMessage(exception); WriteEvent(1, message + exceptionMessage); } [Event(2, Level = EventLevel.Informational)] public void Info(string message, Exception exception) { var exceptionMessage = GenerateExceptionMessage(exception); WriteEvent(2, message + exceptionMessage); } [Event(3, Level = EventLevel.Warning)] public void Warn(string message, Exception exception) { var exceptionMessage = GenerateExceptionMessage(exception); WriteEvent(3, message + exceptionMessage); } [Event(4, Level = EventLevel.Error)] public void Error(string message, Exception exception) { var exceptionMessage = GenerateExceptionMessage(exception); WriteEvent(4, message + exceptionMessage); } [Event(5, Level = EventLevel.Critical)] public void Critical(string message, Exception exception) { var exceptionMessage = GenerateExceptionMessage(exception); WriteEvent(5, message + exceptionMessage); } private static string GenerateExceptionMessage(Exception exception) { return exception != null ? $" Exception message - {exception.Message} :: InnerException - {exception.InnerException} :: StackTrace - {exception.StackTrace}" : ""; } } 

Finally, I initialize and configure the EventSource / EventListener types as follows:

  EventListener genericListener = new StorageFileEventListener("MyIoTListener"); genericListener.EnableEvents(Logger.Log, EventLevel.Critical); 

Did I miss a fundamental step?

+5
source share
1 answer

This is not a solution for the source to appear in the list of custom providers, but provides access to events from the web interface. Just enter the GUID in EventSource into the text field of the custom providers.

On the phone, I have a C # UWP application with the following event source (copied from here )

  [EventSource(Guid = "{GUID of EventSource}", Name = "SourceName")] class MyEventSource : EventSource { public void MyEvent(string msg, int id) { WriteEvent(1, msg, id); } public static MyEventSource Log = new MyEventSource(); } 

I use the Windows Device Portal API ( ... Read events, Send "disable {EventIDourceSource} provider"

All of this works well and well, however, when I request http://127.0.0.1:10080/api/etw/customproviders , the list is still empty.

On the desktop platform, I understand that it uses:

 wevtutil.exe im {App-Manifest}.man 

for a similar purpose, but don't know if this applies to Windows Mobile.

+1
source

Source: https://habr.com/ru/post/1232375/


All Articles