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:
1
public static AppBuilder BuildAvaloniaApp()
2
=> AppBuilder.Configure<App>()
3
.UsePlatformDetect()
4
.LogToTrace();
Copied!
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:
  • Property
  • Binding
  • Animations
  • Visual
  • Layout
  • Control
The LogToTrace method allows specifying which areas are logged:
1
public static AppBuilder BuildAvaloniaApp()
2
=> AppBuilder.Configure<App>()
3
.UsePlatformDetect()
4
.LogToTrace(LogEventLevel.Debug, LogArea.Property, LogArea.Layout);
Copied!
Export as PDF
Copy link
Edit on GitHub
Contents
Areas