Soenneker.Serilog.Sinks.Browser.Blazor 3.0.103

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.103
                    
NuGet\Install-Package Soenneker.Serilog.Sinks.Browser.Blazor -Version 3.0.103
                    
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.103" />
                    
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.103" />
                    
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.103
                    
#r "nuget: Soenneker.Serilog.Sinks.Browser.Blazor, 3.0.103"
                    
#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.103
                    
#: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.103
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Serilog.Sinks.Browser.Blazor&version=3.0.103
                    
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: true);
        });

        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
3.0.196 0 10/16/2025
3.0.195 257 10/14/2025
3.0.194 4,785 9/21/2025
3.0.193 3,514 9/16/2025
3.0.192 1,964 9/10/2025
3.0.191 349 9/9/2025
3.0.190 401 9/9/2025
3.0.189 301 9/9/2025
3.0.188 1,173 9/3/2025
3.0.187 241 9/3/2025
3.0.186 373 9/3/2025
3.0.185 178 9/3/2025
3.0.184 151 9/3/2025
3.0.183 937 8/16/2025
3.0.182 766 8/11/2025
3.0.181 323 8/11/2025
3.0.180 155 8/11/2025
3.0.179 330 8/11/2025
3.0.178 497 8/11/2025
3.0.177 558 8/5/2025
3.0.176 200 8/5/2025
3.0.175 458 7/29/2025
3.0.174 868 7/8/2025
3.0.173 268 7/8/2025
3.0.172 663 7/3/2025
3.0.171 582 6/28/2025
3.0.170 180 6/27/2025
3.0.169 143 6/27/2025
3.0.168 104 6/27/2025
3.0.167 437 6/24/2025
3.0.166 571 6/11/2025
3.0.165 484 6/10/2025
3.0.164 430 6/10/2025
3.0.163 644 6/2/2025
3.0.162 212 6/2/2025
3.0.161 321 5/27/2025
3.0.160 238 5/27/2025
3.0.159 306 5/27/2025
3.0.158 156 5/27/2025
3.0.157 358 5/25/2025
3.0.156 399 5/23/2025
3.0.155 242 5/23/2025
3.0.154 206 5/22/2025
3.0.153 209 5/22/2025
3.0.152 435 5/18/2025
3.0.151 378 5/14/2025
3.0.150 365 5/13/2025
3.0.149 596 5/8/2025
3.0.148 241 5/8/2025
3.0.147 272 5/8/2025
3.0.146 208 5/8/2025
3.0.145 211 5/7/2025
3.0.144 620 5/5/2025
3.0.143 291 5/5/2025
3.0.142 296 5/5/2025
3.0.141 218 5/5/2025
3.0.140 244 5/5/2025
3.0.139 170 5/5/2025
3.0.138 272 5/5/2025
3.0.137 310 5/5/2025
3.0.136 584 4/27/2025
3.0.135 155 4/26/2025
3.0.134 503 4/9/2025
3.0.133 258 4/9/2025
3.0.132 322 4/8/2025
3.0.131 198 4/8/2025
3.0.130 217 4/8/2025
3.0.129 191 4/8/2025
3.0.128 396 4/8/2025
3.0.127 218 4/8/2025
3.0.126 213 4/8/2025
3.0.125 187 4/8/2025
3.0.124 238 4/8/2025
3.0.123 178 4/8/2025
3.0.122 206 4/8/2025
3.0.121 204 4/7/2025
3.0.120 211 4/7/2025
3.0.119 758 4/7/2025
3.0.118 262 4/7/2025
3.0.117 332 4/7/2025
3.0.116 252 4/7/2025
3.0.115 285 4/7/2025
3.0.114 287 4/7/2025
3.0.113 254 4/7/2025
3.0.112 280 4/6/2025
3.0.111 165 4/6/2025
3.0.110 215 4/6/2025
3.0.109 232 4/6/2025
3.0.108 172 4/6/2025
3.0.107 258 4/6/2025
3.0.106 164 4/6/2025
3.0.105 217 4/6/2025
3.0.104 164 4/6/2025
3.0.103 180 4/6/2025
3.0.102 137 4/6/2025
3.0.101 135 4/6/2025
3.0.100 122 4/6/2025
3.0.99 229 4/6/2025
3.0.98 137 4/6/2025
3.0.97 132 4/6/2025
3.0.96 215 4/5/2025
3.0.95 135 4/5/2025
3.0.94 170 4/5/2025
3.0.93 174 4/5/2025
3.0.92 143 4/5/2025
3.0.91 103 4/5/2025
3.0.90 489 4/4/2025
3.0.89 115 4/4/2025
3.0.88 156 4/4/2025
3.0.87 144 4/4/2025
3.0.86 715 4/3/2025
3.0.85 298 4/1/2025
3.0.84 278 4/1/2025
3.0.83 334 3/31/2025
3.0.82 245 3/31/2025
3.0.81 296 3/31/2025
3.0.80 254 3/29/2025
3.0.79 172 3/29/2025
3.0.78 627 3/25/2025
3.0.77 546 3/25/2025
3.0.76 546 3/25/2025
3.0.75 534 3/24/2025
3.0.74 200 3/21/2025
3.0.73 207 3/21/2025
3.0.72 287 3/18/2025
3.0.71 221 3/18/2025
3.0.70 181 3/15/2025
3.0.69 127 3/15/2025
3.0.68 262 3/12/2025
3.0.67 214 3/12/2025
3.0.66 226 3/12/2025
3.0.65 192 3/12/2025
3.0.64 214 3/12/2025
3.0.63 231 3/11/2025
3.0.62 172 3/11/2025
3.0.61 209 3/11/2025
3.0.60 203 3/11/2025
3.0.59 187 3/11/2025
3.0.58 230 3/11/2025
3.0.57 185 3/11/2025
3.0.56 234 3/11/2025
3.0.55 195 3/11/2025
3.0.54 236 3/11/2025
3.0.53 186 3/11/2025
3.0.52 357 3/7/2025
3.0.51 277 3/7/2025
3.0.50 254 3/2/2025
3.0.49 187 3/2/2025
3.0.48 143 3/2/2025
3.0.47 189 3/2/2025
3.0.46 169 3/1/2025
3.0.45 166 3/1/2025
3.0.44 143 3/1/2025
3.0.43 127 3/1/2025
3.0.42 182 3/1/2025
3.0.41 125 3/1/2025
3.0.40 150 3/1/2025
3.0.39 140 3/1/2025
3.0.38 176 3/1/2025
3.0.37 120 3/1/2025
3.0.36 127 3/1/2025
3.0.35 153 3/1/2025
3.0.34 124 3/1/2025
3.0.33 261 2/25/2025
3.0.32 165 2/25/2025
3.0.31 166 2/25/2025
3.0.30 197 2/25/2025
3.0.29 167 2/25/2025
3.0.28 199 2/24/2025
3.0.27 213 2/23/2025
3.0.26 164 2/23/2025
3.0.25 161 2/22/2025
3.0.24 232 2/22/2025
3.0.23 158 2/22/2025
3.0.22 141 2/22/2025
3.0.21 149 2/22/2025
3.0.20 131 2/22/2025
3.0.19 168 2/21/2025
3.0.18 226 2/21/2025
3.0.17 165 2/21/2025
3.0.16 252 2/19/2025
3.0.15 135 2/19/2025
3.0.14 140 2/19/2025
3.0.13 151 2/18/2025
3.0.12 397 2/18/2025
3.0.11 141 2/18/2025
3.0.10 178 2/18/2025
3.0.9 254 2/14/2025
3.0.8 240 2/13/2025
3.0.7 174 2/12/2025
3.0.6 124 2/12/2025
3.0.5 132 2/12/2025
3.0.4 135 2/12/2025
3.0.3 138 2/12/2025
3.0.2 136 2/12/2025
3.0.1 133 2/12/2025