avalonia docs

Logging Errors and Warnings

Avalonia can log warnings and errors using System.Diagnostics.Trace. To enable logging the LogToTrace method call should be present in your Program.cs file:

public static AppBuilder BuildAvaloniaApp()
    => AppBuilder.Configure<App>()
        .UsePlatformDetect()
        .LogToTrace();

By default, this logging setup will write log messages with a severity of Warning or higher to System.Diagnostics.Trace. The severity can be controlled by passing a level parameter to LogToTrace().

Areas

Each Avalonia log message has an "Area" that can be used to filter the log to include only the type of events that you are interested in. These are described by the members of Avalonia.Logging.LogArea static class and are currently:

The LogToTrace method allows specifying which areas are logged:

public static AppBuilder BuildAvaloniaApp()
    => AppBuilder.Configure<App>()
        .UsePlatformDetect()
        .LogToTrace(LogEventLevel.Debug, LogArea.Property, LogArea.Layout);