Soenneker.Serilog.Sinks.Browser.Blazor 3.0.97

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.97
                    
NuGet\Install-Package Soenneker.Serilog.Sinks.Browser.Blazor -Version 3.0.97
                    
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.97" />
                    
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.97" />
                    
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.97
                    
#r "nuget: Soenneker.Serilog.Sinks.Browser.Blazor, 3.0.97"
                    
#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.97
                    
#: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.97
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Serilog.Sinks.Browser.Blazor&version=3.0.97
                    
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
4.0.230 135 1/6/2026
4.0.229 572 1/3/2026
4.0.228 247 1/3/2026
4.0.227 157 1/3/2026
4.0.226 101 1/2/2026
4.0.225 128 1/2/2026
4.0.224 151 1/2/2026
4.0.223 84 1/2/2026
4.0.222 1,004 12/31/2025
4.0.221 536 12/21/2025
4.0.220 1,106 12/15/2025
4.0.219 328 12/15/2025
4.0.218 270 12/15/2025
4.0.217 415 12/12/2025
4.0.216 866 12/10/2025
4.0.215 584 12/9/2025
4.0.214 1,044 11/21/2025
4.0.213 869 11/21/2025
4.0.212 391 11/21/2025
4.0.211 571 11/20/2025
4.0.210 471 11/20/2025
4.0.209 393 11/20/2025
4.0.208 1,374 11/11/2025
4.0.207 463 11/11/2025
4.0.206 865 11/6/2025
4.0.205 147 11/6/2025
4.0.204 350 11/6/2025
4.0.203 808 11/4/2025
4.0.202 851 10/30/2025
4.0.201 260 10/30/2025
4.0.200 282 10/30/2025
4.0.199 199 10/30/2025
4.0.198 276 10/29/2025
4.0.197 187 10/29/2025
3.0.196 1,459 10/16/2025
3.0.195 588 10/14/2025
3.0.194 4,808 9/21/2025
3.0.193 3,530 9/16/2025
3.0.192 1,992 9/10/2025
3.0.191 376 9/9/2025
3.0.190 430 9/9/2025
3.0.189 327 9/9/2025
3.0.188 1,208 9/3/2025
3.0.187 273 9/3/2025
3.0.186 419 9/3/2025
3.0.185 205 9/3/2025
3.0.184 182 9/3/2025
3.0.183 967 8/16/2025
3.0.182 799 8/11/2025
3.0.181 346 8/11/2025
3.0.180 193 8/11/2025
3.0.179 360 8/11/2025
3.0.178 524 8/11/2025
3.0.177 598 8/5/2025
3.0.176 239 8/5/2025
3.0.175 485 7/29/2025
3.0.174 914 7/8/2025
3.0.173 286 7/8/2025
3.0.172 682 7/3/2025
3.0.171 602 6/28/2025
3.0.170 192 6/27/2025
3.0.169 159 6/27/2025
3.0.168 127 6/27/2025
3.0.167 477 6/24/2025
3.0.166 590 6/11/2025
3.0.165 503 6/10/2025
3.0.164 448 6/10/2025
3.0.163 665 6/2/2025
3.0.162 232 6/2/2025
3.0.161 344 5/27/2025
3.0.160 267 5/27/2025
3.0.159 324 5/27/2025
3.0.158 183 5/27/2025
3.0.157 388 5/25/2025
3.0.156 414 5/23/2025
3.0.155 258 5/23/2025
3.0.154 237 5/22/2025
3.0.153 235 5/22/2025
3.0.152 464 5/18/2025
3.0.151 405 5/14/2025
3.0.150 379 5/13/2025
3.0.149 615 5/8/2025
3.0.148 257 5/8/2025
3.0.147 294 5/8/2025
3.0.146 225 5/8/2025
3.0.145 228 5/7/2025
3.0.144 637 5/5/2025
3.0.143 318 5/5/2025
3.0.142 309 5/5/2025
3.0.141 250 5/5/2025
3.0.140 259 5/5/2025
3.0.139 186 5/5/2025
3.0.138 291 5/5/2025
3.0.137 328 5/5/2025
3.0.136 599 4/27/2025
3.0.135 171 4/26/2025
3.0.134 520 4/9/2025
3.0.133 276 4/9/2025
3.0.132 336 4/8/2025
3.0.131 214 4/8/2025
3.0.130 233 4/8/2025
3.0.129 208 4/8/2025
3.0.128 416 4/8/2025
3.0.127 236 4/8/2025
3.0.126 236 4/8/2025
3.0.125 202 4/8/2025
3.0.124 257 4/8/2025
3.0.123 201 4/8/2025
3.0.122 224 4/8/2025
3.0.121 220 4/7/2025
3.0.120 230 4/7/2025
3.0.119 776 4/7/2025
3.0.118 275 4/7/2025
3.0.117 349 4/7/2025
3.0.116 272 4/7/2025
3.0.115 303 4/7/2025
3.0.114 301 4/7/2025
3.0.113 269 4/7/2025
3.0.112 294 4/6/2025
3.0.111 188 4/6/2025
3.0.110 232 4/6/2025
3.0.109 247 4/6/2025
3.0.108 199 4/6/2025
3.0.107 286 4/6/2025
3.0.106 182 4/6/2025
3.0.105 236 4/6/2025
3.0.104 183 4/6/2025
3.0.103 192 4/6/2025
3.0.102 152 4/6/2025
3.0.101 149 4/6/2025
3.0.100 146 4/6/2025
3.0.99 244 4/6/2025
3.0.98 151 4/6/2025
3.0.97 151 4/6/2025
3.0.96 233 4/5/2025
3.0.95 160 4/5/2025
3.0.94 187 4/5/2025
3.0.93 194 4/5/2025
3.0.92 157 4/5/2025
3.0.91 131 4/5/2025
3.0.90 507 4/4/2025
3.0.89 136 4/4/2025
3.0.88 171 4/4/2025
3.0.87 158 4/4/2025
3.0.86 729 4/3/2025
3.0.85 314 4/1/2025
3.0.84 295 4/1/2025
3.0.83 350 3/31/2025
3.0.82 258 3/31/2025
3.0.81 310 3/31/2025
3.0.80 274 3/29/2025
3.0.79 190 3/29/2025
3.0.78 648 3/25/2025
3.0.77 561 3/25/2025
3.0.76 565 3/25/2025
3.0.75 551 3/24/2025
3.0.74 215 3/21/2025
3.0.73 229 3/21/2025
3.0.72 309 3/18/2025
3.0.71 234 3/18/2025
3.0.70 195 3/15/2025
3.0.69 146 3/15/2025
3.0.68 286 3/12/2025
3.0.67 230 3/12/2025
3.0.66 244 3/12/2025
3.0.65 209 3/12/2025
3.0.64 234 3/12/2025
3.0.63 250 3/11/2025
3.0.62 185 3/11/2025
3.0.61 224 3/11/2025
3.0.60 224 3/11/2025
3.0.59 208 3/11/2025
3.0.58 248 3/11/2025
3.0.57 202 3/11/2025
3.0.56 248 3/11/2025
3.0.55 212 3/11/2025
3.0.54 246 3/11/2025
3.0.53 210 3/11/2025
3.0.52 374 3/7/2025
3.0.51 294 3/7/2025
3.0.50 274 3/2/2025
3.0.49 207 3/2/2025
3.0.48 167 3/2/2025
3.0.47 206 3/2/2025
3.0.46 187 3/1/2025
3.0.45 186 3/1/2025
3.0.44 170 3/1/2025
3.0.43 141 3/1/2025
3.0.42 201 3/1/2025
3.0.41 144 3/1/2025
3.0.40 170 3/1/2025
3.0.39 151 3/1/2025
3.0.38 193 3/1/2025
3.0.37 134 3/1/2025
3.0.36 146 3/1/2025
3.0.35 167 3/1/2025
3.0.34 142 3/1/2025
3.0.33 276 2/25/2025
3.0.32 182 2/25/2025
3.0.31 186 2/25/2025
3.0.30 217 2/25/2025
3.0.29 183 2/25/2025
3.0.28 217 2/24/2025
3.0.27 228 2/23/2025
3.0.26 178 2/23/2025
3.0.25 176 2/22/2025
3.0.24 251 2/22/2025
3.0.23 175 2/22/2025
3.0.22 158 2/22/2025
3.0.21 170 2/22/2025
3.0.20 163 2/22/2025
3.0.19 182 2/21/2025
3.0.18 249 2/21/2025
3.0.17 193 2/21/2025
3.0.16 273 2/19/2025
3.0.15 153 2/19/2025
3.0.14 159 2/19/2025
3.0.13 174 2/18/2025
3.0.12 412 2/18/2025
3.0.11 157 2/18/2025
3.0.10 194 2/18/2025
3.0.9 271 2/14/2025
3.0.8 255 2/13/2025
3.0.7 198 2/12/2025
3.0.6 150 2/12/2025
3.0.5 145 2/12/2025
3.0.4 147 2/12/2025
3.0.3 155 2/12/2025
3.0.2 154 2/12/2025
3.0.1 153 2/12/2025