How to collect application logs in windows phone 8.1?

windows-phone-8.1

Solution

Windows 8.1 introduced new classes to simplify logging. These classes are LoggingChannel, LoggingSession and others.

Here's an example:

App.xaml.cs

LoggingSession logSession;
LoggingChannel logChannel;

public App()
{
    this.InitializeComponent();
    this.UnhandledException += App_UnhandledException;
}

void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
    logChannel.LogMessage("Unhandled exception: " + e.Message);
    logSession.SaveToFileAsync(Windows.Storage.ApplicationData.Current.LocalFolder, "MainLog.log").AsTask().Wait();
}

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    logSession = new LoggingSession("MainLogSession");
    Resources["MainLogSession"] = logSession;

    logChannel = new LoggingChannel("AppLogChannel");
    logSession.AddLoggingChannel(logChannel);
}

MainPage.xaml.cs

LoggingChannel logChannel;

public MainPage()
{
    this.InitializeComponent();

    var logSession = (LoggingSession)Application.Current.Resources["MainLogSession"];
    logChannel = new LoggingChannel("MainPageLogChannel");
    logSession.AddLoggingChannel(logChannel);
    logChannel.LogMessage("MainPage ctor", LoggingLevel.Information);
}

I highly recommend watching the Making your Windows Store Apps More Reliable keynote during the 2013 build conference, where Harry Pierson demonstrates these new APIs in more detail (including uploading the log file to a backend server using a background task that gets executed when the phone is connected to AC power).

Problem

I am new to windows phone platform.Is there anything available like logcat in android for windows for collecting logs?Thanks in advance.

Original source