MAUIverse MAUIverse

Logging in .NET MAUI Apps

Logs are most useful next to crash reporting, because they show what happened before the app went down. Tomasz Cielecki describes the approach he takes in many of his apps, starting with the Microsoft.Extensions.Logging abstractions and AddLogging(), with notes on Splat and MvvmCross for projects that don’t use Microsoft.Extensions.DependencyInjection.

Serilog handles where the logs go. He shows a configuration that writes compact JSON (clef) files with rolling and size limits, wraps sinks in Sinks.Async for constrained devices, outputs to the IDE trace window and uses a custom Android log sink. He adds a tip about keeping logs in FileSystem.AppDataDirectory, where they’re private to the app, and exporting them for QA and beta testers. The Sentry section covers AddSentry with the EnableLogs option, which sends entries to Sentry Logs instead of only adding breadcrumbs.

The rest of the post covers practical points. Structured logging with named parameters makes entries searchable by name and value. Filtering noisy contexts such as Polly has to be repeated in the Serilog configuration. Source-generated LoggerMessage methods avoid allocations in hot paths.

It’s a good template if you’re setting up logging in a new app or tidying the logging in an existing one.

View Source →

← Back to Community Feed

}