Skip to main content

Uno Platform Logging

Note that you will need to run with debugging (F5) for some logging and breakpoints/tracepoints to work.

If you want to log regardless of debugging, then using the info function may work for you better.


First, if you simply need to debug something, try using Visual Studio Tracepoints which is nothing but a breakpoint as shown below (use curly braces to print variables). Click the the light grey part on the extreme left, add an action, and voila.

breakpoint screenshot


In your Page.xaml.cs, add the differences

using Uno.Extensions;
using Uno.Logging;

public sealed partial class YourPage : Page {

    private static ILogger _logger { get; } = typeof(YourPage).Log();

    private void ButtonClick(object sender, RoutedEventArgs e) {

        _logger.LogTrace("wont show up, cause we set the LogLevel to be Debug in the next step");
        _logger.Error("qwe", new Exception("zxc"));

In App.xaml.cs and AppHead.xaml.cs, in InitializeLogging above the default filters, modify the first line of code below. I have provided this code in context and it works regardless of where the page is located in your project. For example, the page this blog post is based on is located in a Views directory.

// Custom filters
builder.AddFilter("YourProject.YourPage", LogLevel.Debug);
// Default filters for Uno Platform namespaces [THIS IS ALREADY IN THE FILE]
builder.AddFilter("Uno", LogLevel.Warning);
builder.AddFilter("Windows", LogLevel.Warning);
builder.AddFilter("Microsoft", LogLevel.Warning);

This blog post is adapted from this GitHub discussion