Soenneker.Serilog.Sinks.Browser.Blazor 3.0.191

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Serilog.Sinks.Browser.Blazor --version 3.0.191
                    
NuGet\Install-Package Soenneker.Serilog.Sinks.Browser.Blazor -Version 3.0.191
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Serilog.Sinks.Browser.Blazor" Version="3.0.191" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Serilog.Sinks.Browser.Blazor" Version="3.0.191" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Serilog.Sinks.Browser.Blazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Serilog.Sinks.Browser.Blazor --version 3.0.191
                    
#r "nuget: Soenneker.Serilog.Sinks.Browser.Blazor, 3.0.191"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Serilog.Sinks.Browser.Blazor@3.0.191
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Serilog.Sinks.Browser.Blazor&version=3.0.191
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Serilog.Sinks.Browser.Blazor&version=3.0.191
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Serilog.Sinks.Browser.Blazor

A Serilog sink for logging within the Blazor client-side environment

image

An example demo app has been added to the solution.

🛠 Installation

  1. Install Required NuGet Packages
dotnet add package Soenneker.Serilog.Sinks.Browser.Blazor
  1. Configure Logging in Program.cs

An example:

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.JSInterop;
using Serilog;
using Serilog.Debugging;
using Serilog.Events;
using Soenneker.Serilog.Sinks.Browser.Blazor.Registrars;

public class Program
{
    public static async Task Main(string[] args)
    {
        try
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            ConfigureLogging(builder.Services);

            builder.RootComponents.Add<App>("#app");
            builder.RootComponents.Add<HeadOutlet>("head::after");

            WebAssemblyHost host = builder.Build();

            AddBlazorConsoleLogger(host);

            await host.RunAsync();
        }
        catch (Exception e)
        {
            Log.Error(e, "Stopped program because of exception");
            throw;
        }
        finally
        {
            await Log.CloseAndFlushAsync();
        }
    }

    private static IServiceCollection ConfigureLogging(IServiceCollection services)
    {
        SelfLog.Enable(m => Console.Error.WriteLine(m));

        services.AddLogging(builder =>
        {
            builder.ClearProviders();
            builder.AddSerilog(dispose: false);
        });

        return services;
    }

    private static WebAssemblyHost AddBlazorConsoleLogger(WebAssemblyHost host)
    {
        var jsRuntime = host.Services.GetRequiredService<IJSRuntime>();

        var loggerConfig = new LoggerConfiguration();

        loggerConfig.WriteTo.BlazorConsole(jsRuntime: jsRuntime);

        Log.Logger = loggerConfig.CreateLogger();

        return host;
    }
}

How It Works

  • ConfigureLogging(IServiceCollection services)
    • Enables Serilog's self-logging to capture any internal errors.
    • Registers Serilog as the primary logging provider.
  • SetGlobalLogger(WebAssemblyHost host)
    • Initializes the BlazorConsole sink to log messages directly in the browser's developer console.

🛠 Usage

Once you have installed and configured Serilog with the BlazorConsole sink, you can start logging messages in your Blazor components.

Injecting the Logger

In your Blazor component (.razor file), inject the ILogger<T> service:

@page "/"
@using Microsoft.Extensions.Logging

@inject ILogger<Index> Logger

<button @onclick="Click">Click</button>

@code {
    public void Click()
    {
        Logger.LogInformation("Testing information log");
    }
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.220 436 12/15/2025
4.0.219 145 12/15/2025
4.0.218 104 12/15/2025
4.0.217 403 12/12/2025
4.0.216 853 12/10/2025
4.0.215 574 12/9/2025
4.0.214 1,032 11/21/2025
4.0.213 859 11/21/2025
4.0.212 381 11/21/2025
4.0.211 563 11/20/2025
4.0.210 463 11/20/2025
4.0.209 385 11/20/2025
4.0.208 1,362 11/11/2025
4.0.207 454 11/11/2025
4.0.206 856 11/6/2025
4.0.205 140 11/6/2025
4.0.204 339 11/6/2025
4.0.203 797 11/4/2025
4.0.202 843 10/30/2025
4.0.201 250 10/30/2025
4.0.200 275 10/30/2025
4.0.199 189 10/30/2025
4.0.198 266 10/29/2025
4.0.197 176 10/29/2025
3.0.196 1,452 10/16/2025
3.0.195 578 10/14/2025
3.0.194 4,800 9/21/2025
3.0.193 3,523 9/16/2025
3.0.192 1,984 9/10/2025
3.0.191 369 9/9/2025
3.0.190 423 9/9/2025
3.0.189 321 9/9/2025
3.0.188 1,197 9/3/2025
3.0.187 261 9/3/2025
3.0.186 407 9/3/2025
3.0.185 201 9/3/2025
3.0.184 172 9/3/2025
3.0.183 958 8/16/2025
3.0.182 789 8/11/2025
3.0.181 343 8/11/2025
3.0.180 187 8/11/2025
3.0.179 350 8/11/2025
3.0.178 517 8/11/2025
3.0.177 589 8/5/2025
3.0.176 232 8/5/2025
3.0.175 477 7/29/2025
3.0.174 907 7/8/2025
3.0.173 279 7/8/2025
3.0.172 673 7/3/2025
3.0.171 594 6/28/2025
3.0.170 190 6/27/2025
3.0.169 152 6/27/2025
3.0.168 112 6/27/2025
3.0.167 468 6/24/2025
3.0.166 583 6/11/2025
3.0.165 496 6/10/2025
3.0.164 440 6/10/2025
3.0.163 657 6/2/2025
3.0.162 224 6/2/2025
3.0.161 331 5/27/2025
3.0.160 257 5/27/2025
3.0.159 316 5/27/2025
3.0.158 177 5/27/2025
3.0.157 381 5/25/2025
3.0.156 410 5/23/2025
3.0.155 252 5/23/2025
3.0.154 229 5/22/2025
3.0.153 229 5/22/2025
3.0.152 457 5/18/2025
3.0.151 397 5/14/2025
3.0.150 373 5/13/2025
3.0.149 604 5/8/2025
3.0.148 250 5/8/2025
3.0.147 289 5/8/2025
3.0.146 222 5/8/2025
3.0.145 221 5/7/2025
3.0.144 631 5/5/2025
3.0.143 307 5/5/2025
3.0.142 301 5/5/2025
3.0.141 239 5/5/2025
3.0.140 250 5/5/2025
3.0.139 176 5/5/2025
3.0.138 282 5/5/2025
3.0.137 316 5/5/2025
3.0.136 592 4/27/2025
3.0.135 162 4/26/2025
3.0.134 515 4/9/2025
3.0.133 269 4/9/2025
3.0.132 330 4/8/2025
3.0.131 206 4/8/2025
3.0.130 228 4/8/2025
3.0.129 200 4/8/2025
3.0.128 408 4/8/2025
3.0.127 227 4/8/2025
3.0.126 227 4/8/2025
3.0.125 195 4/8/2025
3.0.124 248 4/8/2025
3.0.123 197 4/8/2025
3.0.122 215 4/8/2025
3.0.121 215 4/7/2025
3.0.120 218 4/7/2025
3.0.119 767 4/7/2025
3.0.118 270 4/7/2025
3.0.117 340 4/7/2025
3.0.116 263 4/7/2025
3.0.115 293 4/7/2025
3.0.114 295 4/7/2025
3.0.113 260 4/7/2025
3.0.112 288 4/6/2025
3.0.111 179 4/6/2025
3.0.110 225 4/6/2025
3.0.109 240 4/6/2025
3.0.108 191 4/6/2025
3.0.107 277 4/6/2025
3.0.106 174 4/6/2025
3.0.105 228 4/6/2025
3.0.104 175 4/6/2025
3.0.103 186 4/6/2025
3.0.102 145 4/6/2025
3.0.101 142 4/6/2025
3.0.100 140 4/6/2025
3.0.99 239 4/6/2025
3.0.98 145 4/6/2025
3.0.97 143 4/6/2025
3.0.96 226 4/5/2025
3.0.95 151 4/5/2025
3.0.94 179 4/5/2025
3.0.93 185 4/5/2025
3.0.92 150 4/5/2025
3.0.91 123 4/5/2025
3.0.90 501 4/4/2025
3.0.89 127 4/4/2025
3.0.88 164 4/4/2025
3.0.87 150 4/4/2025
3.0.86 723 4/3/2025
3.0.85 308 4/1/2025
3.0.84 287 4/1/2025
3.0.83 345 3/31/2025
3.0.82 252 3/31/2025
3.0.81 305 3/31/2025
3.0.80 267 3/29/2025
3.0.79 178 3/29/2025
3.0.78 637 3/25/2025
3.0.77 554 3/25/2025
3.0.76 558 3/25/2025
3.0.75 546 3/24/2025
3.0.74 210 3/21/2025
3.0.73 222 3/21/2025
3.0.72 297 3/18/2025
3.0.71 227 3/18/2025
3.0.70 187 3/15/2025
3.0.69 138 3/15/2025
3.0.68 275 3/12/2025
3.0.67 221 3/12/2025
3.0.66 238 3/12/2025
3.0.65 200 3/12/2025
3.0.64 223 3/12/2025
3.0.63 243 3/11/2025
3.0.62 180 3/11/2025
3.0.61 217 3/11/2025
3.0.60 216 3/11/2025
3.0.59 197 3/11/2025
3.0.58 240 3/11/2025
3.0.57 192 3/11/2025
3.0.56 243 3/11/2025
3.0.55 205 3/11/2025
3.0.54 242 3/11/2025
3.0.53 196 3/11/2025
3.0.52 366 3/7/2025
3.0.51 289 3/7/2025
3.0.50 264 3/2/2025
3.0.49 199 3/2/2025
3.0.48 159 3/2/2025
3.0.47 199 3/2/2025
3.0.46 176 3/1/2025
3.0.45 176 3/1/2025
3.0.44 161 3/1/2025
3.0.43 133 3/1/2025
3.0.42 191 3/1/2025
3.0.41 136 3/1/2025
3.0.40 161 3/1/2025
3.0.39 150 3/1/2025
3.0.38 186 3/1/2025
3.0.37 130 3/1/2025
3.0.36 141 3/1/2025
3.0.35 161 3/1/2025
3.0.34 134 3/1/2025
3.0.33 269 2/25/2025
3.0.32 173 2/25/2025
3.0.31 177 2/25/2025
3.0.30 209 2/25/2025
3.0.29 179 2/25/2025
3.0.28 210 2/24/2025
3.0.27 220 2/23/2025
3.0.26 170 2/23/2025
3.0.25 168 2/22/2025
3.0.24 246 2/22/2025
3.0.23 166 2/22/2025
3.0.22 149 2/22/2025
3.0.21 162 2/22/2025
3.0.20 153 2/22/2025
3.0.19 177 2/21/2025
3.0.18 237 2/21/2025
3.0.17 183 2/21/2025
3.0.16 263 2/19/2025
3.0.15 147 2/19/2025
3.0.14 148 2/19/2025
3.0.13 168 2/18/2025
3.0.12 407 2/18/2025
3.0.11 152 2/18/2025
3.0.10 187 2/18/2025
3.0.9 260 2/14/2025
3.0.8 250 2/13/2025
3.0.7 193 2/12/2025
3.0.6 143 2/12/2025
3.0.5 140 2/12/2025
3.0.4 143 2/12/2025
3.0.3 148 2/12/2025
3.0.2 147 2/12/2025
3.0.1 146 2/12/2025