Search code examples
loggingwindows-runtimewinjswindows-error-reporting

Is there a way to save a Windows.Foundation.Diagnostics.LoggingSession as text in WinJS?


I'm doing the follow to use a LogginSession for saving LogFiles and writing them to a file:

loggingChannel = new Windows.Foundation.Diagnostics.LoggingChannel("FlSMobileLogger");
LoggingSession = new Windows.Foundation.Diagnostics.LoggingSession("FLSMobileLog");
LoggingSession.addLoggingChannel(loggingChannel);

....

function enteredWhenLogEventOccurs(message) {

            var dateString = new Date().toJSON();
            var currentDate = dateString.substring(0, 4) + "-" + dateString.substring(5, 7) + "-" + dateString.substring(8, 10);
            var fileName = "log" + currentDate + ".log";

            loggingChannel.logMessage(message);
            LoggingSession.saveToFileAsync(WinJS.Application.local.folder, fileName);                     
        }

These logsession are saved as binary .etl files. Is there a way to save them as text or convert them in any way?

Thanks in advance!


Solution

  • This command can convert ETL files to XML:

    tracerpt.exe LogFile.etl -of XML -o LogFile.xml
    

    You can find a complete example here:

    https://msdn.microsoft.com/en-us/library/windows/apps/windows.foundation.diagnostics.fileloggingsession