A Serilog sink that takes advantage of the unique features of the browser console in the Blazor/WASM applications.
Versioning: This package tracks the versioning and target framework support of its Microsoft.AspNetCore.Components.WebAssembly dependency. Most users should choose the version of Serilog.Sinks.BrowserConsole that matches their application's target framework. I.e. if you're targeting .NET 7.x, choose a 7.x version of Serilog.Sinks.BrowserConsole. If you're targeting .NET 8.x, choose an 8.x Serilog.Sinks.BrowserConsole version, and so on.
The sink writes log events to the browser console. Unlike the normal Serilog console sink, which writes out formatted text, this sink takes advantage of the unique capabilities of the browser console to print interactive, fully-structured data.
Configure the logging pipeline in Program.Main()
:
// dotnet add package Serilog.Sinks.BrowserConsole
Log.Logger = new LoggerConfiguration()
.WriteTo.BrowserConsole()
.CreateLogger();
Log.Information("Hello, browser!");
A more detailed example is available in this repository.