I have a very simple .NET MAUI app (not a Blazor one). I've installed Seriolog and Serilog.Extensions.Logging (so I can use AppCenter). I have the following in my startup code to initialise Serilog
public static MauiApp CreateMauiApp()
{
// set up logging
var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
path = Path.Combine(path, "debugcode.txt");
Log.Logger = new LoggerConfiguration()
//.MinimumLevel.Debug()
.WriteTo.File(path)
.WriteTo.AppCenterCrashes(restrictedToMinimumLevel: LogEventLevel.Information)
.WriteTo.Console()
.CreateLogger();
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.Logging.AddSerilog(Log.Logger);
return builder.Build();
}
This compiles without an issue. I've added into the main.xaml.cs the code for logging (the code is just the default .NET MAUI test app shipped with VisualStudio). The minimum debug line is commented out, but it makes no difference if it's not commented out.
protected override void OnDisappearing()
{
base.OnDisappearing();
Log.CloseAndFlush();
}
void OnCounterClicked(object sender, EventArgs e)
{
count++;
var nums = $"Current count: {count}";
CounterLabel.Text = nums;
Log.Debug($"***** Current count: {nums}");
SemanticScreenReader.Announce(CounterLabel.Text);
}
I have tried changing the debug level, but no matter what, nothing is showing in the console for the debug information.